feat: forward message and channel invite

This commit is contained in:
zerosoul
2022-04-22 17:06:52 +08:00
parent b34eee726b
commit 5661ade09a
13 changed files with 307 additions and 64 deletions
+11 -8
View File
@@ -6,6 +6,7 @@ import { addUserMsg, removeUserMsg } from "../slices/message.user";
import { addMessage, removeMessage } from "../slices/message";
export const onMessageSendStarted = async (
{
ignoreLocal = false,
id,
content,
type = "text",
@@ -16,9 +17,11 @@ export const onMessageSendStarted = async (
{ dispatch, queryFulfilled },
from = "channel"
) => {
// 忽略archive类型的消息
if (type == "archive") return;
// id: who send to ,from_uid: who sent
console.log("handlers data", content, type, properties);
const isImage = properties.file_type?.startsWith("image");
console.log("handlers data", content, type, properties, ignoreLocal, id);
const isImage = properties.content_type?.startsWith("image");
const ts = properties.local_id || new Date().getTime();
// let imageData = null;
// if (type == "image") {
@@ -39,17 +42,17 @@ export const onMessageSendStarted = async (
properties,
from_uid,
reply_mid,
// 已读
read: true,
sending: true,
};
const addContextMessage = from == "channel" ? addChannelMsg : addUserMsg;
const removeContextMessage =
from == "channel" ? removeChannelMsg : removeUserMsg;
batch(() => {
dispatch(addMessage({ mid: ts, ...tmpMsg }));
dispatch(addContextMessage({ id, mid: ts }));
});
if (!ignoreLocal) {
batch(() => {
dispatch(addMessage({ mid: ts, ...tmpMsg }));
dispatch(addContextMessage({ id, mid: ts }));
});
}
try {
const { data: server_mid } = await queryFulfilled;
+14
View File
@@ -45,6 +45,13 @@ export const messageApi = createApi({
body: meta,
}),
}),
createArchive: builder.mutation({
query: (mids = []) => ({
url: `/resource/archive`,
method: "POST",
body: { mid_list: mids },
}),
}),
uploadFile: builder.mutation({
query: (formData) => ({
// headers: {
@@ -64,6 +71,11 @@ export const messageApi = createApi({
url: `/resource/open_graphic_parse?url=${encodeURIComponent(url)}`,
}),
}),
getArchiveMessage: builder.query({
query: (file_path) => ({
url: `/resource/archive?file_path=${encodeURIComponent(file_path)}`,
}),
}),
replyMessage: builder.mutation({
query: ({ reply_mid, content, type = "text" }) => ({
headers: {
@@ -102,6 +114,7 @@ export const messageApi = createApi({
});
export const {
useGetArchiveMessageQuery,
useLazyGetOGInfoQuery,
usePrepareUploadFileMutation,
useUploadFileMutation,
@@ -110,4 +123,5 @@ export const {
useReplyMessageMutation,
useLazyDeleteMessageQuery,
useReadMessageMutation,
useCreateArchiveMutation,
} = messageApi;
+4
View File
@@ -74,6 +74,9 @@ export const serverApi = createApi({
getSMTPConfig: builder.query({
query: () => ({ url: `admin/smtp/config` }),
}),
getSMTPStatus: builder.query({
query: () => ({ url: `/admin/smtp/enabled` }),
}),
updateSMTPConfig: builder.mutation({
query: (data) => ({
url: `admin/smtp/config`,
@@ -148,6 +151,7 @@ export const serverApi = createApi({
});
export const {
useGetSMTPStatusQuery,
useSendTestEmailMutation,
useUpdateFirebaseConfigMutation,
useGetFirebaseConfigQuery,