From a6e7bbc306a93bd56bb1941e29d6fc474c9c36d5 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Thu, 31 Jan 2019 20:42:45 +0900 Subject: send/receive user hashtags via AP (#4064) --- src/remote/activitypub/models/note.ts | 13 +------------ src/remote/activitypub/models/person.ts | 8 +++++++- src/remote/activitypub/models/tag.ts | 11 +++++++++++ 3 files changed, 19 insertions(+), 13 deletions(-) (limited to 'src/remote/activitypub/models') diff --git a/src/remote/activitypub/models/note.ts b/src/remote/activitypub/models/note.ts index 0f2e515260..1b61435aa2 100644 --- a/src/remote/activitypub/models/note.ts +++ b/src/remote/activitypub/models/note.ts @@ -11,7 +11,7 @@ import { resolveImage } from './image'; import { IRemoteUser, IUser } from '../../../models/user'; import { fromHtml } from '../../../mfm/fromHtml'; import Emoji, { IEmoji } from '../../../models/emoji'; -import { ITag } from './tag'; +import { ITag, extractHashtags } from './tag'; import { toUnicode } from 'punycode'; import { unique, concat, difference } from '../../../prelude/array'; import { extractPollFromQuestion } from './question'; @@ -239,14 +239,3 @@ async function extractMentionedUsers(actor: IRemoteUser, to: string[], cc: strin return users.filter(x => x != null); } - -function extractHashtags(tags: ITag[]) { - if (!tags) return []; - - const hashtags = tags.filter(tag => tag.type === 'Hashtag' && typeof tag.name == 'string'); - - return hashtags.map(tag => { - const m = tag.name.match(/^#(.+)/); - return m ? m[1] : null; - }).filter(x => x != null); -} diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index 54e57f7330..16f1086b86 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -17,7 +17,7 @@ import registerInstance from '../../../services/register-instance'; import Instance from '../../../models/instance'; import getDriveFileUrl from '../../../misc/get-drive-file-url'; import { IEmoji } from '../../../models/emoji'; -import { ITag } from './tag'; +import { ITag, extractHashtags } from './tag'; import Following from '../../../models/following'; import { IIdentifier } from './identifier'; @@ -140,6 +140,8 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise tag.type === 'Hashtag' && typeof tag.name == 'string'); + + return hashtags.map(tag => { + const m = tag.name.match(/^#(.+)/); + return m ? m[1] : null; + }).filter(x => x != null); +} -- cgit v1.2.3-freya