fix: encode base64
This commit is contained in:
@@ -2,7 +2,7 @@ import { createApi } from "@reduxjs/toolkit/query/react";
|
||||
|
||||
import { Channel, ChannelDTO, CreateChannelDTO } from "@/types/channel";
|
||||
import { ContentTypeKey } from "@/types/message";
|
||||
import { transformInviteLink } from "@/utils";
|
||||
import { encodeBase64, transformInviteLink } from "@/utils";
|
||||
import BASE_URL, { ContentTypes } from "../config";
|
||||
import { removeChannel, updateChannel } from "../slices/channels";
|
||||
import { removeMessage } from "../slices/message";
|
||||
@@ -175,7 +175,7 @@ export const channelApi = createApi({
|
||||
query: ({ id, content, type = "text", properties = {} }) => ({
|
||||
headers: {
|
||||
"content-type": ContentTypes[type],
|
||||
"X-Properties": properties ? btoa(JSON.stringify(properties)) : ""
|
||||
"X-Properties": properties ? encodeBase64(JSON.stringify(properties)) : ""
|
||||
},
|
||||
url: `/group/${id}/send`,
|
||||
method: "POST",
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ChatContext } from "@/types/common";
|
||||
import { ChatMessage, ContentTypeKey, UploadFileResponse } from "@/types/message";
|
||||
import { Archive, FavoriteArchive, OG } from "@/types/resource";
|
||||
import handleChatMessage from "@/hooks/useStreaming/chat.handler";
|
||||
import { normalizeArchiveData } from "@/utils";
|
||||
import { encodeBase64, normalizeArchiveData } from "@/utils";
|
||||
import { ContentTypes } from "../config";
|
||||
import { addFavorite, deleteFavorite, fillFavorites, populateFavorite } from "../slices/favorites";
|
||||
import { updateReadChannels, updateReadUsers, upsertOG } from "../slices/footprint";
|
||||
@@ -223,7 +223,7 @@ export const messageApi = createApi({
|
||||
query: ({ reply_mid, content, type = "text", properties }) => ({
|
||||
headers: {
|
||||
"content-type": ContentTypes[type],
|
||||
"X-Properties": properties ? btoa(JSON.stringify(properties)) : ""
|
||||
"X-Properties": properties ? encodeBase64(JSON.stringify(properties)) : ""
|
||||
},
|
||||
url: `/message/${reply_mid}/reply`,
|
||||
method: "POST",
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
TestEmailDTO
|
||||
} from "@/types/server";
|
||||
import { User } from "@/types/user";
|
||||
import { compareVersion } from "@/utils";
|
||||
import { compareVersion, encodeBase64 } from "@/utils";
|
||||
import BASE_URL, {
|
||||
ContentTypes,
|
||||
IS_OFFICIAL_DEMO,
|
||||
@@ -32,6 +32,7 @@ import { updateInfo } from "../slices/server";
|
||||
import { updateCallInfo, upsertVoiceList } from "../slices/voice";
|
||||
import { RootState } from "../store";
|
||||
import baseQuery from "./base.query";
|
||||
import { File, GetFilesDTO } from "@/types/resource";
|
||||
|
||||
export const serverApi = createApi({
|
||||
reducerPath: "serverApi",
|
||||
@@ -238,6 +239,13 @@ export const serverApi = createApi({
|
||||
getLoginConfig: builder.query<LoginConfig, void>({
|
||||
query: () => ({ url: `/admin/login/config` })
|
||||
}),
|
||||
getFiles: builder.query<File[], GetFilesDTO>({
|
||||
query: (params) => ({
|
||||
url: `/admin/system/files?${new URLSearchParams(
|
||||
params as Record<string, string>
|
||||
).toString()}`
|
||||
})
|
||||
}),
|
||||
updateLoginConfig: builder.mutation<void, Partial<LoginConfig>>({
|
||||
query: (data) => ({
|
||||
url: `/admin/login/config`,
|
||||
@@ -328,7 +336,7 @@ export const serverApi = createApi({
|
||||
dispatch(updateInfo({ upgraded: currValue }));
|
||||
}
|
||||
} catch {
|
||||
console.error("update license upgraded status failed ");
|
||||
console.error("get license failed ");
|
||||
}
|
||||
}
|
||||
}),
|
||||
@@ -394,9 +402,7 @@ export const serverApi = createApi({
|
||||
headers: {
|
||||
"x-api-key": api_key,
|
||||
"content-type": ContentTypes[type],
|
||||
"X-Properties": properties
|
||||
? btoa(unescape(encodeURIComponent(JSON.stringify(properties))))
|
||||
: ""
|
||||
"X-Properties": properties ? encodeBase64(JSON.stringify(properties)) : ""
|
||||
},
|
||||
url: cid ? `/bot/send_to_group/${cid}` : `/bot/send_to_user/${uid}`,
|
||||
method: "POST",
|
||||
@@ -449,5 +455,6 @@ export const {
|
||||
useGenerateAgoraTokenMutation,
|
||||
useLazyGetAgoraUsersByChannelQuery,
|
||||
useLazyClearAllFilesQuery,
|
||||
useLazyClearAllMessagesQuery
|
||||
useLazyClearAllMessagesQuery,
|
||||
useLazyGetFilesQuery
|
||||
} = serverApi;
|
||||
|
||||
@@ -20,6 +20,7 @@ import { RootState } from "../store";
|
||||
// import toast from "react-hot-toast";
|
||||
import baseQuery from "./base.query";
|
||||
import { onMessageSendStarted } from "./handlers";
|
||||
import { encodeBase64 } from "@/utils";
|
||||
|
||||
export const userApi = createApi({
|
||||
reducerPath: "userApi",
|
||||
@@ -230,7 +231,7 @@ export const userApi = createApi({
|
||||
query: ({ id, content, type = "text", properties = "" }) => ({
|
||||
headers: {
|
||||
"content-type": ContentTypes[type],
|
||||
"X-Properties": properties ? btoa(JSON.stringify(properties)) : ""
|
||||
"X-Properties": properties ? encodeBase64(JSON.stringify(properties)) : ""
|
||||
},
|
||||
url: `/user/${id}/send`,
|
||||
method: "POST",
|
||||
|
||||
@@ -433,3 +433,4 @@ export const transformInviteLink = (link: string) => {
|
||||
};
|
||||
|
||||
export const isInIframe = () => window.location !== window.parent.location;
|
||||
export const encodeBase64 = (str = "") => btoa(unescape(encodeURIComponent(str)));
|
||||
|
||||
Reference in New Issue
Block a user