mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-12-22 08:20:10 +00:00
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/647 Closes #686 and #696 Approved-by: Marie <github@yuugi.dev> Approved-by: dakkar <dakkar@thenautilus.net>
This commit is contained in:
commit
a90b4d487a
11 changed files with 57 additions and 10 deletions
|
@ -167,7 +167,7 @@ id: 'aidx'
|
|||
# IP address family used for outgoing request (ipv4, ipv6 or dual)
|
||||
#outgoingAddressFamily: ipv4
|
||||
|
||||
# Amount of characters that can be used when writing notes (maximum: 8192, minimum: 1)
|
||||
# Amount of characters that can be used when writing notes (maximum: 100000, minimum: 1)
|
||||
maxNoteLength: 3000
|
||||
|
||||
# Proxy for HTTP/HTTPS
|
||||
|
|
|
@ -242,7 +242,7 @@ id: 'aidx'
|
|||
# IP address family used for outgoing request (ipv4, ipv6 or dual)
|
||||
#outgoingAddressFamily: ipv4
|
||||
|
||||
# Amount of characters that can be used when writing notes (maximum: 8192, minimum: 1)
|
||||
# Amount of characters that can be used when writing notes (maximum: 100000, minimum: 1)
|
||||
maxNoteLength: 3000
|
||||
|
||||
# Proxy for HTTP/HTTPS
|
||||
|
|
|
@ -251,7 +251,7 @@ id: 'aidx'
|
|||
# IP address family used for outgoing request (ipv4, ipv6 or dual)
|
||||
#outgoingAddressFamily: ipv4
|
||||
|
||||
# Amount of characters that can be used when writing notes (maximum: 8192, minimum: 1)
|
||||
# Amount of characters that can be used when writing notes (maximum: 100000, minimum: 1)
|
||||
maxNoteLength: 3000
|
||||
|
||||
# Proxy for HTTP/HTTPS
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class IncreaseCharacterLimits1727998351561 {
|
||||
name = 'IncreaseCharacterLimits1727998351561'
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "drive_file" ALTER COLUMN "comment" TYPE varchar(100000)`);
|
||||
await queryRunner.query(`ALTER TABLE "note" ALTER COLUMN "cw" TYPE text`);
|
||||
}
|
||||
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "note" ALTER COLUMN "cw" TYPE varchar(512)`);
|
||||
await queryRunner.query(`ALTER TABLE "drive_file" ALTER COLUMN "comment" TYPE varchar(8192)`);
|
||||
}
|
||||
}
|
|
@ -13,15 +13,16 @@ export const USER_ACTIVE_THRESHOLD = 1000 * 60 * 60 * 24 * 3; // 3days
|
|||
|
||||
/**
|
||||
* Maximum note text length that can be stored in DB.
|
||||
* Content Warnings are included in this limit.
|
||||
* Surrogate pairs count as one
|
||||
*/
|
||||
export const DB_MAX_NOTE_TEXT_LENGTH = 8192;
|
||||
export const DB_MAX_NOTE_TEXT_LENGTH = 100000;
|
||||
|
||||
/**
|
||||
* Maximum image description length that can be stored in DB.
|
||||
* Surrogate pairs count as one
|
||||
*/
|
||||
export const DB_MAX_IMAGE_COMMENT_LENGTH = 8192;
|
||||
export const DB_MAX_IMAGE_COMMENT_LENGTH = 100000;
|
||||
//#endregion
|
||||
|
||||
// ブラウザで直接表示することを許可するファイルの種類のリスト
|
||||
|
|
|
@ -351,6 +351,18 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
data.text = null;
|
||||
}
|
||||
|
||||
if (data.cw) {
|
||||
if (data.cw.length > DB_MAX_NOTE_TEXT_LENGTH) {
|
||||
data.cw = data.cw.slice(0, DB_MAX_NOTE_TEXT_LENGTH);
|
||||
}
|
||||
data.cw = data.cw.trim();
|
||||
if (data.cw === '') {
|
||||
data.cw = null;
|
||||
}
|
||||
} else {
|
||||
data.cw = null;
|
||||
}
|
||||
|
||||
let tags = data.apHashtags;
|
||||
let emojis = data.apEmojis;
|
||||
let mentionedUsers = data.apMentions;
|
||||
|
|
|
@ -371,6 +371,18 @@ export class NoteEditService implements OnApplicationShutdown {
|
|||
data.text = null;
|
||||
}
|
||||
|
||||
if (data.cw) {
|
||||
if (data.cw.length > DB_MAX_NOTE_TEXT_LENGTH) {
|
||||
data.cw = data.cw.slice(0, DB_MAX_NOTE_TEXT_LENGTH);
|
||||
}
|
||||
data.cw = data.cw.trim();
|
||||
if (data.cw === '') {
|
||||
data.cw = null;
|
||||
}
|
||||
} else {
|
||||
data.cw = null;
|
||||
}
|
||||
|
||||
let tags = data.apHashtags;
|
||||
let emojis = data.apEmojis;
|
||||
let mentionedUsers = data.apMentions;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
|
||||
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
|
||||
import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/const.js';
|
||||
import { id } from './util/id.js';
|
||||
import { MiUser } from './User.js';
|
||||
import { MiDriveFolder } from './DriveFolder.js';
|
||||
|
@ -61,7 +62,7 @@ export class MiDriveFile {
|
|||
public size: number;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 8192,
|
||||
length: DB_MAX_IMAGE_COMMENT_LENGTH,
|
||||
nullable: true,
|
||||
comment: 'The comment of the DriveFile.',
|
||||
})
|
||||
|
|
|
@ -66,8 +66,8 @@ export class MiNote {
|
|||
})
|
||||
public name: string | null;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 512, nullable: true,
|
||||
@Column('text', {
|
||||
nullable: true,
|
||||
})
|
||||
public cw: string | null;
|
||||
|
||||
|
|
|
@ -252,7 +252,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
private noteCreateService: NoteCreateService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
if (ps.text && (ps.text.length > this.config.maxNoteLength)) {
|
||||
const contentLength = (ps.text?.length ?? 0) + (ps.cw?.length ?? 0);
|
||||
if (contentLength > this.config.maxNoteLength) {
|
||||
throw new ApiError(meta.errors.maxLength);
|
||||
}
|
||||
|
||||
|
|
|
@ -297,9 +297,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
private noteEditService: NoteEditService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
if (ps.text && (ps.text.length > this.config.maxNoteLength)) {
|
||||
const contentLength = (ps.text?.length ?? 0) + (ps.cw?.length ?? 0);
|
||||
if (contentLength > this.config.maxNoteLength) {
|
||||
throw new ApiError(meta.errors.maxLength);
|
||||
}
|
||||
|
||||
let visibleUsers: MiUser[] = [];
|
||||
if (ps.visibleUserIds) {
|
||||
visibleUsers = await this.usersRepository.findBy({
|
||||
|
|
Loading…
Reference in a new issue