Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accepts Article object #4499

Merged
merged 1 commit into from Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/models/note.ts
Expand Up @@ -41,6 +41,7 @@ export type INote = {
replyId: mongo.ObjectID;
renoteId: mongo.ObjectID;
poll: IPoll;
name?: string;
text: string;
tags: string[];
tagsLower: string[];
Expand Down Expand Up @@ -391,6 +392,10 @@ export const pack = async (
}
//#endregion

if (_note.name) {
_note.text = `【${_note.name}】\n${_note.text}`;
}

if (_note.user.isCat && _note.text) {
_note.text = (_note.text
// ja-JP
Expand Down
4 changes: 1 addition & 3 deletions src/remote/activitypub/kernel/announce/index.ts
Expand Up @@ -24,10 +24,8 @@ export default async (actor: IRemoteUser, activity: IAnnounce): Promise<void> =>

switch (object.type) {
case 'Note':
announceNote(resolver, actor, activity, object as INote);
break;

case 'Question':
case 'Article':
announceNote(resolver, actor, activity, object as INote);
break;

Expand Down
4 changes: 1 addition & 3 deletions src/remote/activitypub/kernel/create/index.ts
Expand Up @@ -29,10 +29,8 @@ export default async (actor: IRemoteUser, activity: ICreate): Promise<void> => {
break;

case 'Note':
createNote(resolver, actor, object);
break;

case 'Question':
case 'Article':
createNote(resolver, actor, object);
break;

Expand Down
4 changes: 1 addition & 3 deletions src/remote/activitypub/kernel/delete/index.ts
Expand Up @@ -21,10 +21,8 @@ export default async (actor: IRemoteUser, activity: IDelete): Promise<void> => {

switch (object.type) {
case 'Note':
deleteNote(actor, uri);
break;

case 'Question':
case 'Article':
deleteNote(actor, uri);
break;

Expand Down
3 changes: 2 additions & 1 deletion src/remote/activitypub/models/note.ts
Expand Up @@ -57,7 +57,7 @@ export async function createNote(value: any, resolver?: Resolver, silent = false

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}`, {
resolver: {
history: resolver.getHistory()
Expand Down Expand Up @@ -199,6 +199,7 @@ export async function createNote(value: any, resolver?: Resolver, silent = false
files,
reply,
renote: quote,
name: note.name,
cw,
text,
viaMobile: false,
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/endpoints/ap/show.ts
Expand Up @@ -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);
return {
type: 'Note',
Expand Down
2 changes: 2 additions & 0 deletions src/services/note/create.ts
Expand Up @@ -91,6 +91,7 @@ class NotificationManager {

type Option = {
createdAt?: Date;
name?: string;
text?: string;
reply?: INote;
renote?: INote;
Expand Down Expand Up @@ -437,6 +438,7 @@ async function insertNote(user: IUser, data: Option, tags: string[], emojis: str
fileIds: data.files ? data.files.map(file => file._id) : [],
replyId: data.reply ? data.reply._id : null,
renoteId: data.renote ? data.renote._id : null,
name: data.name,
text: data.text,
poll: data.poll,
cw: data.cw == null ? null : data.cw,
Expand Down