apply note mandatory CW through NoteEditService
This commit is contained in:
parent
a04f49b932
commit
1413be08a0
3 changed files with 15 additions and 13 deletions
|
|
@ -144,6 +144,7 @@ type Option = {
|
|||
url?: string | null;
|
||||
app?: MiApp | null;
|
||||
processErrors?: string[] | null;
|
||||
mandatoryCW?: string | null;
|
||||
};
|
||||
|
||||
export type PureRenoteOption = Option & { renote: MiNote } & ({ text?: null } | { cw?: null } | { reply?: null } | { poll?: null } | { files?: null | [] });
|
||||
|
|
@ -477,6 +478,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
renoteUserHost: data.renote ? data.renote.userHost : null,
|
||||
userHost: user.host,
|
||||
processErrors: data.processErrors,
|
||||
mandatoryCW: data.mandatoryCW,
|
||||
});
|
||||
|
||||
// should really not happen, but better safe than sorry
|
||||
|
|
|
|||
|
|
@ -224,13 +224,7 @@ export class NoteEditService implements OnApplicationShutdown {
|
|||
}
|
||||
|
||||
@bindThis
|
||||
public async edit(user: MiUser & {
|
||||
id: MiUser['id'];
|
||||
username: MiUser['username'];
|
||||
host: MiUser['host'];
|
||||
isBot: MiUser['isBot'];
|
||||
noindex: MiUser['noindex'];
|
||||
}, editid: MiNote['id'], data: Option, silent = false): Promise<MiNote> {
|
||||
public async edit(user: MiUser, editid: MiNote['id'], data: Option, silent = false): Promise<MiNote> {
|
||||
if (!editid) {
|
||||
throw new UnrecoverableError('edit failed: missing editid');
|
||||
}
|
||||
|
|
@ -457,6 +451,9 @@ export class NoteEditService implements OnApplicationShutdown {
|
|||
if (oldnote.hasPoll !== !!data.poll) {
|
||||
update.hasPoll = !!data.poll;
|
||||
}
|
||||
if (data.mandatoryCW !== undefined && oldnote.mandatoryCW !== data.mandatoryCW) {
|
||||
update.mandatoryCW = data.mandatoryCW;
|
||||
}
|
||||
|
||||
// TODO deep-compare files
|
||||
const filesChanged = oldnote.fileIds.length || data.files?.length;
|
||||
|
|
@ -518,6 +515,7 @@ export class NoteEditService implements OnApplicationShutdown {
|
|||
renoteUserHost: data.renote ? data.renote.userHost : null,
|
||||
userHost: user.host,
|
||||
reactionAndUserPairCache: oldnote.reactionAndUserPairCache,
|
||||
mandatoryCW: data.mandatoryCW,
|
||||
});
|
||||
|
||||
if (data.uri != null) note.uri = data.uri;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue