mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 04:39:06 +00:00
Update zulip message
This commit is contained in:
@@ -16,6 +16,11 @@ from reflector.db.transcripts import (
|
||||
from reflector.processors.types import Transcript as ProcessorTranscript
|
||||
from reflector.processors.types import Word
|
||||
from reflector.settings import settings
|
||||
from reflector.zulip import (
|
||||
get_zulip_message,
|
||||
send_message_to_zulip,
|
||||
update_zulip_message,
|
||||
)
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -323,3 +328,28 @@ async def transcript_get_topics_with_words_per_speaker(
|
||||
|
||||
# convert to GetTranscriptTopicWithWordsPerSpeaker
|
||||
return GetTranscriptTopicWithWordsPerSpeaker.from_transcript_topic(topic)
|
||||
|
||||
|
||||
@router.post("/transcripts/{transcript_id}/zulip")
|
||||
async def transcript_post_to_zulip(
|
||||
transcript_id: str,
|
||||
stream: str,
|
||||
topic: str,
|
||||
include_topics: bool,
|
||||
user: Annotated[Optional[auth.UserInfo], Depends(auth.current_user_optional)],
|
||||
):
|
||||
user_id = user["sub"] if user else None
|
||||
transcript = await transcripts_controller.get_by_id_for_http(
|
||||
transcript_id, user_id=user_id
|
||||
)
|
||||
if not transcript:
|
||||
raise HTTPException(status_code=404, detail="Transcript not found")
|
||||
|
||||
content = get_zulip_message(transcript, include_topics)
|
||||
if transcript.zulip_message_id:
|
||||
update_zulip_message(transcript.zulip_message_id, stream, topic, content)
|
||||
else:
|
||||
response = send_message_to_zulip(stream, topic, content)
|
||||
await transcripts_controller.update(
|
||||
transcript, {"zulip_message_id": response["id"]}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user