mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-21 04:25:27 -04:00
patch: hot patch to prevent gif abuse
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "module",
|
||||
"name": "revolt.js",
|
||||
"version": "5.2.1-patch.6",
|
||||
"version": "5.2.2",
|
||||
"main": "dist/index.js",
|
||||
"repository": "https://github.com/revoltchat/revolt.js",
|
||||
"author": "Paul Makles <insrt.uk>",
|
||||
|
||||
+11
-3
@@ -3,7 +3,7 @@ import EventEmitter from "eventemitter3";
|
||||
import defaultsDeep from "lodash.defaultsdeep";
|
||||
import { action, makeObservable, observable } from "mobx";
|
||||
import type { Session } from "revolt-api/types/Auth";
|
||||
import type { SizeOptions } from "revolt-api/types/Autumn";
|
||||
import type { Attachment, AttachmentMetadata, SizeOptions } from "revolt-api/types/Autumn";
|
||||
import type { RevoltConfiguration } from "revolt-api/types/Core";
|
||||
import { MemberCompositeKey, Role } from "revolt-api/types/Servers";
|
||||
|
||||
@@ -498,7 +498,7 @@ export class Client extends EventEmitter {
|
||||
* @returns Generated URL or nothing
|
||||
*/
|
||||
generateFileURL(
|
||||
attachment?: { tag: string; _id: string; content_type?: string },
|
||||
attachment?: { tag: string; _id: string; content_type?: string, metadata?: AttachmentMetadata },
|
||||
...args: FileArgs
|
||||
) {
|
||||
const [options, allowAnimation, fallback] = args;
|
||||
@@ -507,7 +507,15 @@ export class Client extends EventEmitter {
|
||||
if (!autumn?.enabled) return fallback;
|
||||
if (!attachment) return fallback;
|
||||
|
||||
const { tag, _id, content_type } = attachment;
|
||||
const { tag, _id, content_type, metadata } = attachment;
|
||||
|
||||
// ! FIXME: These limits should be done on Autumn.
|
||||
if (metadata?.type === 'Image') {
|
||||
if (Math.min(metadata.width, metadata.height) <= 0 ||
|
||||
(content_type === "image/gif"
|
||||
&& Math.max(metadata.width, metadata.height) >= 1024))
|
||||
return fallback;
|
||||
}
|
||||
|
||||
let query = "";
|
||||
if (options) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
export const LIBRARY_VERSION = "5.2.1-patch.6";
|
||||
export const LIBRARY_VERSION = "5.2.2";
|
||||
|
||||
export const defaultConfig = {
|
||||
apiURL: "https://api.revolt.chat",
|
||||
|
||||
Reference in New Issue
Block a user