View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/881 Closes #901 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
d629b882b0
12 changed files with 178 additions and 7 deletions
|
|
@ -49,11 +49,13 @@ import { IdService } from '@/core/IdService.js';
|
|||
import type { AnnouncementService } from '@/core/AnnouncementService.js';
|
||||
import type { CustomEmojiService } from '@/core/CustomEmojiService.js';
|
||||
import { AvatarDecorationService } from '@/core/AvatarDecorationService.js';
|
||||
import { isSystemAccount } from '@/misc/is-system-account.js';
|
||||
import type { OnModuleInit } from '@nestjs/common';
|
||||
import type { NoteEntityService } from './NoteEntityService.js';
|
||||
import type { DriveFileEntityService } from './DriveFileEntityService.js';
|
||||
import type { PageEntityService } from './PageEntityService.js';
|
||||
import { isSystemAccount } from '@/misc/is-system-account.js';
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
const Ajv = _Ajv.default;
|
||||
const ajv = new Ajv();
|
||||
|
|
@ -669,6 +671,8 @@ export class UserEntityService implements OnModuleInit {
|
|||
achievements: profile!.achievements,
|
||||
loggedInDays: profile!.loggedInDates.length,
|
||||
policies: this.roleService.getUserPolicies(user.id),
|
||||
defaultCW: profile!.defaultCW,
|
||||
defaultCWPriority: profile!.defaultCWPriority,
|
||||
} : {}),
|
||||
|
||||
...(opts.includeSecrets ? {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import { Entity, Column, Index, OneToOne, JoinColumn, PrimaryColumn } from 'typeorm';
|
||||
import { obsoleteNotificationTypes, followingVisibilities, followersVisibilities, notificationTypes } from '@/types.js';
|
||||
import { obsoleteNotificationTypes, followingVisibilities, followersVisibilities, notificationTypes, noteVisibilities, defaultCWPriorities } from '@/types.js';
|
||||
import { id } from './util/id.js';
|
||||
import { MiUser } from './User.js';
|
||||
import { MiPage } from './Page.js';
|
||||
|
|
@ -36,10 +36,10 @@ export class MiUserProfile {
|
|||
})
|
||||
public birthday: string | null;
|
||||
|
||||
@Column("varchar", {
|
||||
@Column('varchar', {
|
||||
length: 128,
|
||||
nullable: true,
|
||||
comment: "The ListenBrainz username of the User.",
|
||||
comment: 'The ListenBrainz username of the User.',
|
||||
})
|
||||
public listenbrainz: string | null;
|
||||
|
||||
|
|
@ -290,6 +290,19 @@ export class MiUserProfile {
|
|||
unlockedAt: number;
|
||||
}[];
|
||||
|
||||
@Column('text', {
|
||||
name: 'default_cw',
|
||||
nullable: true,
|
||||
})
|
||||
public defaultCW: string | null;
|
||||
|
||||
@Column('enum', {
|
||||
name: 'default_cw_priority',
|
||||
enum: defaultCWPriorities,
|
||||
default: 'parent',
|
||||
})
|
||||
public defaultCWPriority: typeof defaultCWPriorities[number];
|
||||
|
||||
//#region Denormalized fields
|
||||
@Index()
|
||||
@Column('varchar', {
|
||||
|
|
|
|||
|
|
@ -752,6 +752,15 @@ export const packedMeDetailedOnlySchema = {
|
|||
},
|
||||
},
|
||||
//#endregion
|
||||
defaultCW: {
|
||||
type: 'string',
|
||||
nullable: true, optional: false,
|
||||
},
|
||||
defaultCWPriority: {
|
||||
type: 'string',
|
||||
enum: ['default', 'parent', 'defaultParent', 'parentDefault'],
|
||||
nullable: false, optional: false,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,12 @@ export const meta = {
|
|||
id: '0b3f9f6a-2f4d-4b1f-9fb4-49d3a2fd7191',
|
||||
httpStatusCode: 422,
|
||||
},
|
||||
|
||||
maxCwLength: {
|
||||
message: 'You tried setting a default content warning which is too long.',
|
||||
code: 'MAX_CW_LENGTH',
|
||||
id: '7004c478-bda3-4b4f-acb2-4316398c9d52',
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
|
|
@ -243,6 +249,12 @@ export const paramDef = {
|
|||
uniqueItems: true,
|
||||
items: { type: 'string' },
|
||||
},
|
||||
defaultCW: { type: 'string', nullable: true },
|
||||
defaultCWPriority: {
|
||||
type: 'string',
|
||||
enum: ['default', 'parent', 'defaultParent', 'parentDefault'],
|
||||
nullable: false,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
|
@ -494,6 +506,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
updates.alsoKnownAs = newAlsoKnownAs.size > 0 ? Array.from(newAlsoKnownAs) : null;
|
||||
}
|
||||
|
||||
let defaultCW = ps.defaultCW;
|
||||
if (defaultCW !== undefined) {
|
||||
if (defaultCW === '') defaultCW = null;
|
||||
if (defaultCW && defaultCW.length > this.config.maxCwLength) {
|
||||
throw new ApiError(meta.errors.maxCwLength);
|
||||
}
|
||||
|
||||
profileUpdates.defaultCW = defaultCW;
|
||||
}
|
||||
if (ps.defaultCWPriority !== undefined) {
|
||||
profileUpdates.defaultCWPriority = ps.defaultCWPriority;
|
||||
}
|
||||
|
||||
//#region emojis/tags
|
||||
|
||||
let emojis = [] as string[];
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ export const mutedNoteReasons = ['word', 'manual', 'spam', 'other'] as const;
|
|||
export const followingVisibilities = ['public', 'followers', 'private'] as const;
|
||||
export const followersVisibilities = ['public', 'followers', 'private'] as const;
|
||||
|
||||
export const defaultCWPriorities = ['default', 'parent', 'defaultParent', 'parentDefault'] as const;
|
||||
|
||||
/**
|
||||
* ユーザーがエクスポートできるものの種類
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue