Accept Article object (#4499)
This commit is contained in:
parent
68d43e43b6
commit
56eb896a03
@ -41,6 +41,7 @@ export type INote = {
|
|||||||
replyId: mongo.ObjectID;
|
replyId: mongo.ObjectID;
|
||||||
renoteId: mongo.ObjectID;
|
renoteId: mongo.ObjectID;
|
||||||
poll: IPoll;
|
poll: IPoll;
|
||||||
|
name?: string;
|
||||||
text: string;
|
text: string;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
tagsLower: string[];
|
tagsLower: string[];
|
||||||
@ -391,6 +392,10 @@ export const pack = async (
|
|||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
if (_note.name) {
|
||||||
|
_note.text = `【${_note.name}】\n${_note.text}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (_note.user.isCat && _note.text) {
|
if (_note.user.isCat && _note.text) {
|
||||||
_note.text = (_note.text
|
_note.text = (_note.text
|
||||||
// ja-JP
|
// ja-JP
|
||||||
|
@ -24,10 +24,8 @@ export default async (actor: IRemoteUser, activity: IAnnounce): Promise<void> =>
|
|||||||
|
|
||||||
switch (object.type) {
|
switch (object.type) {
|
||||||
case 'Note':
|
case 'Note':
|
||||||
announceNote(resolver, actor, activity, object as INote);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'Question':
|
case 'Question':
|
||||||
|
case 'Article':
|
||||||
announceNote(resolver, actor, activity, object as INote);
|
announceNote(resolver, actor, activity, object as INote);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -29,10 +29,8 @@ export default async (actor: IRemoteUser, activity: ICreate): Promise<void> => {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Note':
|
case 'Note':
|
||||||
createNote(resolver, actor, object);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'Question':
|
case 'Question':
|
||||||
|
case 'Article':
|
||||||
createNote(resolver, actor, object);
|
createNote(resolver, actor, object);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -21,10 +21,8 @@ export default async (actor: IRemoteUser, activity: IDelete): Promise<void> => {
|
|||||||
|
|
||||||
switch (object.type) {
|
switch (object.type) {
|
||||||
case 'Note':
|
case 'Note':
|
||||||
deleteNote(actor, uri);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'Question':
|
case 'Question':
|
||||||
|
case 'Article':
|
||||||
deleteNote(actor, uri);
|
deleteNote(actor, uri);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ export async function createNote(value: any, resolver?: Resolver, silent = false
|
|||||||
|
|
||||||
const object: any = await resolver.resolve(value);
|
const object: any = await resolver.resolve(value);
|
||||||
|
|
||||||
if (!object || !['Note', 'Question'].includes(object.type)) {
|
if (!object || !['Note', 'Question', 'Article'].includes(object.type)) {
|
||||||
logger.error(`invalid note: ${value}`, {
|
logger.error(`invalid note: ${value}`, {
|
||||||
resolver: {
|
resolver: {
|
||||||
history: resolver.getHistory()
|
history: resolver.getHistory()
|
||||||
@ -199,6 +199,7 @@ export async function createNote(value: any, resolver?: Resolver, silent = false
|
|||||||
files,
|
files,
|
||||||
reply,
|
reply,
|
||||||
renote: quote,
|
renote: quote,
|
||||||
|
name: note.name,
|
||||||
cw,
|
cw,
|
||||||
text,
|
text,
|
||||||
viaMobile: false,
|
viaMobile: false,
|
||||||
|
@ -103,7 +103,7 @@ async function fetchAny(uri: string) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['Note', 'Question'].includes(object.type)) {
|
if (['Note', 'Question', 'Article'].includes(object.type)) {
|
||||||
const note = await createNote(object.id);
|
const note = await createNote(object.id);
|
||||||
return {
|
return {
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
|
@ -91,6 +91,7 @@ class NotificationManager {
|
|||||||
|
|
||||||
type Option = {
|
type Option = {
|
||||||
createdAt?: Date;
|
createdAt?: Date;
|
||||||
|
name?: string;
|
||||||
text?: string;
|
text?: string;
|
||||||
reply?: INote;
|
reply?: INote;
|
||||||
renote?: INote;
|
renote?: INote;
|
||||||
@ -437,6 +438,7 @@ async function insertNote(user: IUser, data: Option, tags: string[], emojis: str
|
|||||||
fileIds: data.files ? data.files.map(file => file._id) : [],
|
fileIds: data.files ? data.files.map(file => file._id) : [],
|
||||||
replyId: data.reply ? data.reply._id : null,
|
replyId: data.reply ? data.reply._id : null,
|
||||||
renoteId: data.renote ? data.renote._id : null,
|
renoteId: data.renote ? data.renote._id : null,
|
||||||
|
name: data.name,
|
||||||
text: data.text,
|
text: data.text,
|
||||||
poll: data.poll,
|
poll: data.poll,
|
||||||
cw: data.cw == null ? null : data.cw,
|
cw: data.cw == null ? null : data.cw,
|
||||||
|
Loading…
Reference in New Issue
Block a user