summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-06-21 16:37:43 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-06-21 16:37:43 +0900
commit8dbdab4a470f0bb263a22d634ec0a8dd3fa2df1d (patch)
tree707d2915e50a9e62f92b5f758b47d9bf1aea4324 /src
parentchore(client): Improve emoji picker usability (diff)
parentプロフィールの「場所」「誕生日」を連合するように Reso... (diff)
downloadsharkey-8dbdab4a470f0bb263a22d634ec0a8dd3fa2df1d.tar.gz
sharkey-8dbdab4a470f0bb263a22d634ec0a8dd3fa2df1d.tar.bz2
sharkey-8dbdab4a470f0bb263a22d634ec0a8dd3fa2df1d.zip
Merge branch 'develop' of https://github.com/syuilo/misskey into develop
Diffstat (limited to 'src')
-rw-r--r--src/misc/nyaize.ts4
-rw-r--r--src/remote/activitypub/models/person.ts8
-rw-r--r--src/remote/activitypub/renderer/index.ts3
-rw-r--r--src/remote/activitypub/renderer/person.ts14
-rw-r--r--src/remote/activitypub/type.ts2
5 files changed, 28 insertions, 3 deletions
diff --git a/src/misc/nyaize.ts b/src/misc/nyaize.ts
index 6ee3b68477..500d1db2cb 100644
--- a/src/misc/nyaize.ts
+++ b/src/misc/nyaize.ts
@@ -3,7 +3,9 @@ export function nyaize(text: string): string {
// ja-JP
.replace(/な/g, 'にゃ').replace(/ナ/g, 'ニャ').replace(/ナ/g, 'ニャ')
// en-US
- .replace(/morning/gi, 'mornyan').replace(/everyone/gi, 'everynyan')
+ .replace(/(?<=n)a/gi, x => x === 'A' ? 'YA' : 'ya')
+ .replace(/(?<=morn)ing/gi, x => x === 'ING' ? 'YAN' : 'yan')
+ .replace(/(?<=every)one/gi, x => x === 'ONE' ? 'NYAN' : 'nyan')
// ko-KR
.replace(/[나-낳]/g, match => String.fromCharCode(
match.charCodeAt(0)! + '냐'.charCodeAt(0) - '나'.charCodeAt(0)
diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts
index 4b8fa9a551..a3093786d0 100644
--- a/src/remote/activitypub/models/person.ts
+++ b/src/remote/activitypub/models/person.ts
@@ -138,6 +138,8 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us
const isBot = object.type === 'Service';
+ const bday = person['vcard:bday']?.match(/^\d{4}-\d{2}-\d{2}/);
+
// Create user
let user: IRemoteUser;
try {
@@ -168,6 +170,8 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us
description: person.summary ? htmlToMfm(person.summary, person.tag) : null,
url: getOneApHrefNullable(person.url),
fields,
+ birthday: bday ? bday[0] : null,
+ location: person['vcard:Address'] || null,
userHost: host
}));
@@ -319,6 +323,8 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint
const tags = extractApHashtags(person.tag).map(tag => tag.toLowerCase()).splice(0, 32);
+ const bday = person['vcard:bday']?.match(/^\d{4}-\d{2}-\d{2}/);
+
const updates = {
lastFetchedAt: new Date(),
inbox: person.inbox,
@@ -356,6 +362,8 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint
url: getOneApHrefNullable(person.url),
fields,
description: person.summary ? htmlToMfm(person.summary, person.tag) : null,
+ birthday: bday ? bday[0] : null,
+ location: person['vcard:Address'] || null,
});
// ハッシュタグ更新
diff --git a/src/remote/activitypub/renderer/index.ts b/src/remote/activitypub/renderer/index.ts
index e84a7d90ac..cf0fd8d85a 100644
--- a/src/remote/activitypub/renderer/index.ts
+++ b/src/remote/activitypub/renderer/index.ts
@@ -49,6 +49,9 @@ export const attachLdSignature = async (activity: any, user: ILocalUser): Promis
'_misskey_reaction': 'misskey:_misskey_reaction',
'_misskey_votes': 'misskey:_misskey_votes',
'_misskey_talk': 'misskey:_misskey_talk',
+ 'isCat': 'misskey:isCat',
+ // vcard
+ vcard: 'http://www.w3.org/2006/vcard/ns#',
};
activity['@context'].push(obj);
diff --git a/src/remote/activitypub/renderer/person.ts b/src/remote/activitypub/renderer/person.ts
index bc8a462d2e..87dca19acd 100644
--- a/src/remote/activitypub/renderer/person.ts
+++ b/src/remote/activitypub/renderer/person.ts
@@ -52,7 +52,7 @@ export async function renderPerson(user: ILocalUser) {
const keypair = await UserKeypairs.findOne(user.id).then(ensure);
- return {
+ const person = {
type: isSystem ? 'Application' : user.isBot ? 'Service' : 'Person',
id,
inbox: `${id}/inbox`,
@@ -73,5 +73,15 @@ export async function renderPerson(user: ILocalUser) {
publicKey: renderKey(user, keypair, `#main-key`),
isCat: user.isCat,
attachment: attachment.length ? attachment : undefined
- };
+ } as any;
+
+ if (profile?.birthday) {
+ person['vcard:bday'] = profile.birthday;
+ }
+
+ if (profile?.location) {
+ person['vcard:Address'] = profile.location;
+ }
+
+ return person;
}
diff --git a/src/remote/activitypub/type.ts b/src/remote/activitypub/type.ts
index d47a0967f9..0533506cdc 100644
--- a/src/remote/activitypub/type.ts
+++ b/src/remote/activitypub/type.ts
@@ -140,6 +140,8 @@ export interface IPerson extends IObject {
endpoints?: {
sharedInbox?: string;
};
+ 'vcard:bday'?: string;
+ 'vcard:Address'?: string;
}
export const isCollection = (object: IObject): object is ICollection =>