mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-12-04 01:38:05 +09:00
Expand caption limit to 1500 characters
This commit is contained in:
parent
5eca395fcd
commit
be4d51fcad
@ -96,6 +96,9 @@ id: 'aid'
|
|||||||
# Max note length, should be < 8000.
|
# Max note length, should be < 8000.
|
||||||
#maxNoteLength: 3000
|
#maxNoteLength: 3000
|
||||||
|
|
||||||
|
# Maximum lenght of an image caption or file comment (default 1500, max 8192)
|
||||||
|
#maxCaptionLength: 1500
|
||||||
|
|
||||||
# Whether disable HSTS
|
# Whether disable HSTS
|
||||||
#disableHsts: true
|
#disableHsts: true
|
||||||
|
|
||||||
|
11
packages/backend/migration/1677935903517-DriveComment.js
Normal file
11
packages/backend/migration/1677935903517-DriveComment.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
export class DriveComment1677935903517 {
|
||||||
|
name = 'DriveComment1677935903517'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "drive_file" ALTER "comment" TYPE character varying(8192)`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "drive_file" ALTER "comment" TYPE character varying(512)`);
|
||||||
|
}
|
||||||
|
}
|
@ -74,6 +74,7 @@ export type Source = {
|
|||||||
maxUserSignups?: number;
|
maxUserSignups?: number;
|
||||||
isManagedHosting?: boolean;
|
isManagedHosting?: boolean;
|
||||||
maxNoteLength?: number;
|
maxNoteLength?: number;
|
||||||
|
maxCaptionLength?: number;
|
||||||
deepl: {
|
deepl: {
|
||||||
managed?: boolean;
|
managed?: boolean;
|
||||||
authKey?: string;
|
authKey?: string;
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import config from "@/config/index.js";
|
import config from "@/config/index.js";
|
||||||
|
import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js";
|
||||||
|
|
||||||
export const MAX_NOTE_TEXT_LENGTH =
|
export const MAX_NOTE_TEXT_LENGTH =
|
||||||
config.maxNoteLength != null ? config.maxNoteLength : 3000; // <- should we increase this?
|
config.maxNoteLength != null ? config.maxNoteLength : 3000; // <- should we increase this?
|
||||||
|
export const MAX_CAPTION_TEXT_LENGTH = Math.min(
|
||||||
|
config.maxCaptionLength ?? 1500,
|
||||||
|
DB_MAX_IMAGE_COMMENT_LENGTH,
|
||||||
|
);
|
||||||
|
|
||||||
export const SECOND = 1000;
|
export const SECOND = 1000;
|
||||||
export const SEC = 1000; // why do we need this duplicate here?
|
export const SEC = 1000; // why do we need this duplicate here?
|
||||||
|
@ -10,4 +10,4 @@ export const DB_MAX_NOTE_TEXT_LENGTH = 8192;
|
|||||||
* Maximum image description length that can be stored in DB.
|
* Maximum image description length that can be stored in DB.
|
||||||
* Surrogate pairs count as one
|
* Surrogate pairs count as one
|
||||||
*/
|
*/
|
||||||
export const DB_MAX_IMAGE_COMMENT_LENGTH = 512;
|
export const DB_MAX_IMAGE_COMMENT_LENGTH = 8192;
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
import { id } from "../id.js";
|
import { id } from "../id.js";
|
||||||
import { User } from "./user.js";
|
import { User } from "./user.js";
|
||||||
import { DriveFolder } from "./drive-folder.js";
|
import { DriveFolder } from "./drive-folder.js";
|
||||||
|
import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Index(['userId', 'folderId', 'id'])
|
@Index(['userId', 'folderId', 'id'])
|
||||||
@ -69,7 +70,8 @@ export class DriveFile {
|
|||||||
public size: number;
|
public size: number;
|
||||||
|
|
||||||
@Column('varchar', {
|
@Column('varchar', {
|
||||||
length: 512, nullable: true,
|
length: DB_MAX_IMAGE_COMMENT_LENGTH,
|
||||||
|
nullable: true,
|
||||||
comment: 'The comment of the DriveFile.',
|
comment: 'The comment of the DriveFile.',
|
||||||
})
|
})
|
||||||
public comment: string | null;
|
public comment: string | null;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import config from "@/config/index.js";
|
import config from "@/config/index.js";
|
||||||
import { fetchMeta } from "@/misc/fetch-meta.js";
|
import { fetchMeta } from "@/misc/fetch-meta.js";
|
||||||
import { MAX_NOTE_TEXT_LENGTH } from "@/const.js";
|
import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js";
|
||||||
import define from "../../define.js";
|
import define from "../../define.js";
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
@ -86,6 +86,11 @@ export const meta = {
|
|||||||
optional: false,
|
optional: false,
|
||||||
nullable: false,
|
nullable: false,
|
||||||
},
|
},
|
||||||
|
maxCaptionTextLength: {
|
||||||
|
type: "number",
|
||||||
|
optional: false,
|
||||||
|
nullable: false,
|
||||||
|
},
|
||||||
emojis: {
|
emojis: {
|
||||||
type: "array",
|
type: "array",
|
||||||
optional: false,
|
optional: false,
|
||||||
@ -499,6 +504,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||||||
backgroundImageUrl: instance.backgroundImageUrl,
|
backgroundImageUrl: instance.backgroundImageUrl,
|
||||||
logoImageUrl: instance.logoImageUrl,
|
logoImageUrl: instance.logoImageUrl,
|
||||||
maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, // 後方互換性のため
|
maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, // 後方互換性のため
|
||||||
|
maxCaptionTextLength: MAX_CAPTION_TEXT_LENGTH,
|
||||||
defaultLightTheme: instance.defaultLightTheme,
|
defaultLightTheme: instance.defaultLightTheme,
|
||||||
defaultDarkTheme: instance.defaultDarkTheme,
|
defaultDarkTheme: instance.defaultDarkTheme,
|
||||||
enableEmail: instance.enableEmail,
|
enableEmail: instance.enableEmail,
|
||||||
|
@ -2,8 +2,7 @@ import { IsNull, MoreThan } from "typeorm";
|
|||||||
import config from "@/config/index.js";
|
import config from "@/config/index.js";
|
||||||
import { fetchMeta } from "@/misc/fetch-meta.js";
|
import { fetchMeta } from "@/misc/fetch-meta.js";
|
||||||
import { Ads, Emojis, Users } from "@/models/index.js";
|
import { Ads, Emojis, Users } from "@/models/index.js";
|
||||||
import { DB_MAX_NOTE_TEXT_LENGTH } from "@/misc/hard-limits.js";
|
import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js";
|
||||||
import { MAX_NOTE_TEXT_LENGTH } from "@/const.js";
|
|
||||||
import define from "../define.js";
|
import define from "../define.js";
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
@ -178,6 +177,11 @@ export const meta = {
|
|||||||
optional: false,
|
optional: false,
|
||||||
nullable: false,
|
nullable: false,
|
||||||
},
|
},
|
||||||
|
maxCaptionTextLength: {
|
||||||
|
type: "number",
|
||||||
|
optional: false,
|
||||||
|
nullable: false,
|
||||||
|
},
|
||||||
emojis: {
|
emojis: {
|
||||||
type: "array",
|
type: "array",
|
||||||
optional: false,
|
optional: false,
|
||||||
@ -456,6 +460,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||||||
backgroundImageUrl: instance.backgroundImageUrl,
|
backgroundImageUrl: instance.backgroundImageUrl,
|
||||||
logoImageUrl: instance.logoImageUrl,
|
logoImageUrl: instance.logoImageUrl,
|
||||||
maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, // 後方互換性のため
|
maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, // 後方互換性のため
|
||||||
|
maxCaptionTextLength: MAX_CAPTION_TEXT_LENGTH,
|
||||||
emojis: instance.privateMode && !me ? [] : await Emojis.packMany(emojis),
|
emojis: instance.privateMode && !me ? [] : await Emojis.packMany(emojis),
|
||||||
defaultLightTheme: instance.defaultLightTheme,
|
defaultLightTheme: instance.defaultLightTheme,
|
||||||
defaultDarkTheme: instance.defaultDarkTheme,
|
defaultDarkTheme: instance.defaultDarkTheme,
|
||||||
|
@ -3,7 +3,7 @@ import config from "@/config/index.js";
|
|||||||
import { fetchMeta } from "@/misc/fetch-meta.js";
|
import { fetchMeta } from "@/misc/fetch-meta.js";
|
||||||
import { Users, Notes } from "@/models/index.js";
|
import { Users, Notes } from "@/models/index.js";
|
||||||
import { IsNull, MoreThan } from "typeorm";
|
import { IsNull, MoreThan } from "typeorm";
|
||||||
import { MAX_NOTE_TEXT_LENGTH } from "@/const.js";
|
import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js";
|
||||||
import { Cache } from "@/misc/cache.js";
|
import { Cache } from "@/misc/cache.js";
|
||||||
|
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
@ -85,6 +85,7 @@ const nodeinfo2 = async () => {
|
|||||||
enableHcaptcha: meta.enableHcaptcha,
|
enableHcaptcha: meta.enableHcaptcha,
|
||||||
enableRecaptcha: meta.enableRecaptcha,
|
enableRecaptcha: meta.enableRecaptcha,
|
||||||
maxNoteTextLength: MAX_NOTE_TEXT_LENGTH,
|
maxNoteTextLength: MAX_NOTE_TEXT_LENGTH,
|
||||||
|
maxCaptionTextLength: MAX_CAPTION_TEXT_LENGTH,
|
||||||
enableTwitterIntegration: meta.enableTwitterIntegration,
|
enableTwitterIntegration: meta.enableTwitterIntegration,
|
||||||
enableGithubIntegration: meta.enableGithubIntegration,
|
enableGithubIntegration: meta.enableGithubIntegration,
|
||||||
enableDiscordIntegration: meta.enableDiscordIntegration,
|
enableDiscordIntegration: meta.enableDiscordIntegration,
|
||||||
|
@ -39,6 +39,7 @@ import MkButton from '@/components/MkButton.vue';
|
|||||||
import bytes from '@/filters/bytes';
|
import bytes from '@/filters/bytes';
|
||||||
import number from '@/filters/number';
|
import number from '@/filters/number';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
|
import { instance } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -87,8 +88,9 @@ export default defineComponent({
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
remainingLength(): number {
|
remainingLength(): number {
|
||||||
if (typeof this.inputValue !== "string") return 512;
|
const maxCaptionLength = instance.maxCaptionTextLength ?? 512;
|
||||||
return 512 - length(this.inputValue);
|
if (typeof this.inputValue !== "string") return maxCaptionLength;
|
||||||
|
return maxCaptionLength - length(this.inputValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user