diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2018-09-01 21:38:49 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-01 21:38:49 +0900 |
| commit | 4b1886990f7de0a1b993b2f3f17c3ee99f78a5ec (patch) | |
| tree | 15426a39bf9b6d30c1ddb50a61e070d5bda6300a /src/remote | |
| parent | 8.20.0 (diff) | |
| parent | Send Update activity (diff) | |
| download | misskey-4b1886990f7de0a1b993b2f3f17c3ee99f78a5ec.tar.gz misskey-4b1886990f7de0a1b993b2f3f17c3ee99f78a5ec.tar.bz2 misskey-4b1886990f7de0a1b993b2f3f17c3ee99f78a5ec.zip | |
Merge pull request #2570 from mei23/mei-0901-update2b
Implement ActivityPub Update(Person)
Diffstat (limited to 'src/remote')
| -rw-r--r-- | src/remote/activitypub/models/person.ts | 18 | ||||
| -rw-r--r-- | src/remote/activitypub/renderer/update.ts | 14 |
2 files changed, 28 insertions, 4 deletions
diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index 3bd4e16763..dff38f5460 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -139,6 +139,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<IU avatarId: null, bannerId: null, createdAt: Date.parse(person.published) || null, + updatedAt: new Date(), description: htmlToMFM(person.summary), followersCount, followingCount, @@ -215,10 +216,12 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<IU /** * Personの情報を更新します。 - * * Misskeyに対象のPersonが登録されていなければ無視します。 + * @param uri URI of Person + * @param resolver Resolver + * @param hint Hint of Person object (この値が正当なPersonの場合、Remote resolveをせずに更新に利用します) */ -export async function updatePerson(uri: string, resolver?: Resolver): Promise<void> { +export async function updatePerson(uri: string, resolver?: Resolver, hint?: object): Promise<void> { if (typeof uri !== 'string') throw 'uri is not string'; // URIがこのサーバーを指しているならスキップ @@ -236,7 +239,7 @@ export async function updatePerson(uri: string, resolver?: Resolver): Promise<vo if (resolver == null) resolver = new Resolver(); - const object = await resolver.resolve(uri) as any; + const object = hint || await resolver.resolve(uri) as any; const err = validatePerson(object, uri); @@ -290,7 +293,14 @@ export async function updatePerson(uri: string, resolver?: Resolver): Promise<vo name: person.name, url: person.url, endpoints: person.endpoints, - isCat: (person as any).isCat === true ? true : false + isBot: object.type == 'Service', + isCat: (person as any).isCat === true ? true : false, + isLocked: person.manuallyApprovesFollowers, + createdAt: Date.parse(person.published) || null, + publicKey: { + id: person.publicKey.id, + publicKeyPem: person.publicKey.publicKeyPem + }, } }); } diff --git a/src/remote/activitypub/renderer/update.ts b/src/remote/activitypub/renderer/update.ts new file mode 100644 index 0000000000..cf9acc9acb --- /dev/null +++ b/src/remote/activitypub/renderer/update.ts @@ -0,0 +1,14 @@ +import config from '../../../config'; +import { ILocalUser } from '../../../models/user'; + +export default (object: any, user: ILocalUser) => { + const activity = { + id: `${config.url}/users/${user._id}#updates/${new Date().getTime()}`, + actor: `${config.url}/users/${user._id}`, + type: 'Update', + to: [ 'https://www.w3.org/ns/activitystreams#Public' ], + object + } as any; + + return activity; +}; |