mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
Update zulip message
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import React, { useContext, useState, useEffect } from "react";
|
||||
import React, { useContext, useState, useEffect, useCallback } from "react";
|
||||
import SelectSearch from "react-select-search";
|
||||
import { getZulipMessage, sendZulipMessage } from "../../../lib/zulip";
|
||||
import { GetTranscript, GetTranscriptTopic } from "../../../api";
|
||||
import "react-select-search/style.css";
|
||||
import { DomainContext } from "../../../domainContext";
|
||||
import useApi from "../../../lib/useApi";
|
||||
|
||||
type ShareModal = {
|
||||
show: boolean;
|
||||
@@ -30,6 +30,7 @@ const ShareModal = (props: ShareModal) => {
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [streams, setStreams] = useState<Stream[]>([]);
|
||||
const { zulip_streams } = useContext(DomainContext);
|
||||
const api = useApi();
|
||||
|
||||
useEffect(() => {
|
||||
fetch(zulip_streams + "/streams.json")
|
||||
@@ -52,12 +53,22 @@ const ShareModal = (props: ShareModal) => {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleSendToZulip = () => {
|
||||
const handleSendToZulip = async () => {
|
||||
if (!props.transcript) return;
|
||||
|
||||
const msg = getZulipMessage(props.transcript, props.topics, includeTopics);
|
||||
|
||||
if (stream && topic) sendZulipMessage(stream, topic, msg);
|
||||
if (stream && topic) {
|
||||
if (!api) return;
|
||||
try {
|
||||
await api.v1TranscriptPostToZulip({
|
||||
transcriptId: props.transcript.id,
|
||||
stream,
|
||||
topic,
|
||||
includeTopics,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (props.show && isLoading) {
|
||||
|
||||
@@ -30,6 +30,8 @@ import type {
|
||||
V1TranscriptGetTopicsWithWordsResponse,
|
||||
V1TranscriptGetTopicsWithWordsPerSpeakerData,
|
||||
V1TranscriptGetTopicsWithWordsPerSpeakerResponse,
|
||||
V1TranscriptPostToZulipData,
|
||||
V1TranscriptPostToZulipResponse,
|
||||
V1TranscriptHeadAudioMp3Data,
|
||||
V1TranscriptHeadAudioMp3Response,
|
||||
V1TranscriptGetAudioMp3Data,
|
||||
@@ -373,6 +375,36 @@ export class DefaultService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Transcript Post To Zulip
|
||||
* @param data The data for the request.
|
||||
* @param data.transcriptId
|
||||
* @param data.stream
|
||||
* @param data.topic
|
||||
* @param data.includeTopics
|
||||
* @returns unknown Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public v1TranscriptPostToZulip(
|
||||
data: V1TranscriptPostToZulipData,
|
||||
): CancelablePromise<V1TranscriptPostToZulipResponse> {
|
||||
return this.httpRequest.request({
|
||||
method: "POST",
|
||||
url: "/v1/transcripts/{transcript_id}/zulip",
|
||||
path: {
|
||||
transcript_id: data.transcriptId,
|
||||
},
|
||||
query: {
|
||||
stream: data.stream,
|
||||
topic: data.topic,
|
||||
include_topics: data.includeTopics,
|
||||
},
|
||||
errors: {
|
||||
422: "Validation Error",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Transcript Get Audio Mp3
|
||||
* @param data The data for the request.
|
||||
|
||||
@@ -319,6 +319,15 @@ export type V1TranscriptGetTopicsWithWordsPerSpeakerData = {
|
||||
export type V1TranscriptGetTopicsWithWordsPerSpeakerResponse =
|
||||
GetTranscriptTopicWithWordsPerSpeaker;
|
||||
|
||||
export type V1TranscriptPostToZulipData = {
|
||||
includeTopics: boolean;
|
||||
stream: string;
|
||||
topic: string;
|
||||
transcriptId: string;
|
||||
};
|
||||
|
||||
export type V1TranscriptPostToZulipResponse = unknown;
|
||||
|
||||
export type V1TranscriptHeadAudioMp3Data = {
|
||||
token?: string | null;
|
||||
transcriptId: string;
|
||||
@@ -614,6 +623,21 @@ export type $OpenApiTs = {
|
||||
};
|
||||
};
|
||||
};
|
||||
"/v1/transcripts/{transcript_id}/zulip": {
|
||||
post: {
|
||||
req: V1TranscriptPostToZulipData;
|
||||
res: {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: unknown;
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HTTPValidationError;
|
||||
};
|
||||
};
|
||||
};
|
||||
"/v1/transcripts/{transcript_id}/audio/mp3": {
|
||||
head: {
|
||||
req: V1TranscriptHeadAudioMp3Data;
|
||||
|
||||
Reference in New Issue
Block a user