🐛 fix message sticker sending

This commit is contained in:
Flam3rboy 2021-10-15 00:03:05 +02:00
parent f38ebe65ed
commit d8f77c687e
5 changed files with 18 additions and 4 deletions

View File

@ -37,6 +37,7 @@
HTML_TIMESTAMP: Date.now(), HTML_TIMESTAMP: Date.now(),
ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0" ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0"
}; };
GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST;
const localStorage = window.localStorage; const localStorage = window.localStorage;
// TODO: remote auth // TODO: remote auth
// window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, ""); // window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, "");
@ -105,7 +106,8 @@
} }
const settings = JSON.parse(localStorage.getItem("UserSettingsStore")); const settings = JSON.parse(localStorage.getItem("UserSettingsStore"));
if (settings && settings.locale === "en") { if (settings && settings.locale.length <= 2) {
// fix client locale wrong and client not loading at all
settings.locale = "en-US"; settings.locale = "en-US";
localStorage.setItem("UserSettingsStore", JSON.stringify(settings)); localStorage.setItem("UserSettingsStore", JSON.stringify(settings));
} }

View File

@ -63,6 +63,7 @@ export interface MessageCreateSchema {
payload_json?: string; payload_json?: string;
file?: any; file?: any;
attachments?: any[]; //TODO we should create an interface for attachments attachments?: any[]; //TODO we should create an interface for attachments
sticker_ids?: string[];
} }
// https://discord.com/developers/docs/resources/channel#create-message // https://discord.com/developers/docs/resources/channel#create-message

View File

@ -0,0 +1,10 @@
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
const router = Router();
router.get("/subscriptions", route({}), async (req: Request, res: Response) => {
// TODO:
res.json([]);
});
export default router;

View File

@ -24,7 +24,7 @@ import fetch from "node-fetch";
import cheerio from "cheerio"; import cheerio from "cheerio";
import { MessageCreateSchema } from "../routes/channels/#channel_id/messages"; import { MessageCreateSchema } from "../routes/channels/#channel_id/messages";
// TODO: check webhook, application, system author // TODO: check webhook, application, system author, stickers
// TODO: embed gifs/videos/images // TODO: embed gifs/videos/images
const LINK_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g; const LINK_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g;
@ -46,6 +46,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
const message = new Message({ const message = new Message({
...opts, ...opts,
sticker_items: opts.sticker_ids?.map((x) => ({ id: x })),
guild_id: channel.guild_id, guild_id: channel.guild_id,
channel_id: opts.channel_id, channel_id: opts.channel_id,
attachments: opts.attachments || [], attachments: opts.attachments || [],
@ -82,7 +83,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
} }
// TODO: stickers/activity // TODO: stickers/activity
if (!opts.content && !opts.embeds?.length && !opts.attachments?.length) { if (!opts.content && !opts.embeds?.length && !opts.attachments?.length && !opts.sticker_ids?.length) {
throw new HTTPError("Empty messages are not allowed", 50006); throw new HTTPError("Empty messages are not allowed", 50006);
} }

View File

@ -127,7 +127,7 @@ export class Message extends BaseClass {
mention_channels: Channel[]; mention_channels: Channel[];
@JoinTable({ name: "message_stickers" }) @JoinTable({ name: "message_stickers" })
@ManyToMany(() => Sticker) @ManyToMany(() => Sticker, { cascade: true, onDelete: "CASCADE" })
sticker_items?: Sticker[]; sticker_items?: Sticker[];
@OneToMany(() => Attachment, (attachment: Attachment) => attachment.message, { @OneToMany(() => Attachment, (attachment: Attachment) => attachment.message, {