summaryrefslogtreecommitdiff
path: root/src/remote/activitypub
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2018-12-11 20:18:12 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2018-12-11 20:18:12 +0900
commit638d81b66ee48bab0264ab9bb71fd3feddad5a14 (patch)
treed2301331fef5df8eded0b7b065173045d9121a6f /src/remote/activitypub
parentUpdate ja-JP.yml (diff)
downloadmisskey-638d81b66ee48bab0264ab9bb71fd3feddad5a14.tar.gz
misskey-638d81b66ee48bab0264ab9bb71fd3feddad5a14.tar.bz2
misskey-638d81b66ee48bab0264ab9bb71fd3feddad5a14.zip
Show user fields (#3590)
Diffstat (limited to 'src/remote/activitypub')
-rw-r--r--src/remote/activitypub/models/person.ts23
-rw-r--r--src/remote/activitypub/models/tag.ts1
2 files changed, 24 insertions, 0 deletions
diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts
index 9bbc41e628..6f62da5ca7 100644
--- a/src/remote/activitypub/models/person.ts
+++ b/src/remote/activitypub/models/person.ts
@@ -17,6 +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';
const log = debug('misskey:activitypub');
@@ -135,6 +136,10 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<IU
const host = toUnicode(new URL(object.id).hostname.toLowerCase());
+ const fields = await extractFields(person.attachment).catch(e => {
+ console.log(`cat not extract fields: ${e}`);
+ });
+
const isBot = object.type == 'Service';
// Create user
@@ -164,6 +169,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<IU
endpoints: person.endpoints,
uri: person.id,
url: person.url,
+ fields,
isBot: isBot,
isCat: (person as any).isCat === true
}) as IRemoteUser;
@@ -325,6 +331,10 @@ export async function updatePerson(uri: string, resolver?: Resolver, hint?: obje
const emojiNames = emojis.map(emoji => emoji.name);
+ const fields = await extractFields(person.attachment).catch(e => {
+ console.log(`cat not extract fields: ${e}`);
+ });
+
// Update user
await User.update({ _id: exist._id }, {
$set: {
@@ -346,6 +356,7 @@ export async function updatePerson(uri: string, resolver?: Resolver, hint?: obje
name: person.name,
url: person.url,
endpoints: person.endpoints,
+ fields,
isBot: object.type == 'Service',
isCat: (person as any).isCat === true,
isLocked: person.manuallyApprovesFollowers,
@@ -382,6 +393,18 @@ export async function resolvePerson(uri: string, verifier?: string, resolver?: R
return await createPerson(uri, resolver);
}
+export async function extractFields(attachments: ITag[]) {
+ if (!attachments) return [];
+
+ return attachments.filter(a => a.type === 'PropertyValue' && a.name && a.value)
+ .map(a => {
+ return {
+ name: a.name,
+ value: htmlToMFM(a.value)
+ };
+ });
+}
+
export async function updateFeatured(userId: mongo.ObjectID) {
const user = await User.findOne({ _id: userId });
if (!isRemoteUser(user)) return;
diff --git a/src/remote/activitypub/models/tag.ts b/src/remote/activitypub/models/tag.ts
index 5cdbfa43b1..7c9b41eb22 100644
--- a/src/remote/activitypub/models/tag.ts
+++ b/src/remote/activitypub/models/tag.ts
@@ -7,6 +7,7 @@ export type ITag = {
id: string;
type: string;
name?: string;
+ value?: string;
updated?: Date;
icon?: IIcon;
};