From 1f53d1a149e2f2f3ac37fc332c62dc8f012beb52 Mon Sep 17 00:00:00 2001 From: mei23 Date: Sat, 25 Aug 2018 12:32:31 +0900 Subject: [PATCH 1/9] Send Content-Type in ActivityPub request --- src/remote/activitypub/request.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts index 585c1c0ce..cebce8c48 100644 --- a/src/remote/activitypub/request.ts +++ b/src/remote/activitypub/request.ts @@ -19,6 +19,9 @@ export default (user: ILocalUser, url: string, object: any) => new Promise((reso port, method: 'POST', path: pathname + search, + headers: { + 'Content-Type': 'application/activity+json' + } }, res => { log(`${url} --> ${res.statusCode}`); From edb61e52c5f3619d818c280b0e852368d2fbc09a Mon Sep 17 00:00:00 2001 From: mei23 Date: Sat, 25 Aug 2018 12:46:06 +0900 Subject: [PATCH 2/9] Use resolvable ActivityPub keyId --- src/remote/activitypub/request.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts index cebce8c48..6238d3acb 100644 --- a/src/remote/activitypub/request.ts +++ b/src/remote/activitypub/request.ts @@ -35,7 +35,7 @@ export default (user: ILocalUser, url: string, object: any) => new Promise((reso sign(req, { authorizationHeaderName: 'Signature', key: user.keypair, - keyId: `acct:${user.username}@${config.host}` + keyId: `${config.url}/users/${user._id}/publickey` }); // Signature: Signature ... => Signature: ... From 92828028db28c92d7d36324d445a69d62351df48 Mon Sep 17 00:00:00 2001 From: mei23 Date: Sat, 25 Aug 2018 13:11:54 +0900 Subject: [PATCH 3/9] Add Activity id if missing --- src/remote/activitypub/renderer/index.ts | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/remote/activitypub/renderer/index.ts b/src/remote/activitypub/renderer/index.ts index ee7f49616..55b2801ca 100644 --- a/src/remote/activitypub/renderer/index.ts +++ b/src/remote/activitypub/renderer/index.ts @@ -1,7 +1,16 @@ -export default (x: any) => Object.assign({ - '@context': [ - 'https://www.w3.org/ns/activitystreams', - 'https://w3id.org/security/v1', - { Hashtag: 'as:Hashtag' } - ] -}, x); +import config from '../../../config'; +import * as uuid from 'uuid'; + +export default (x: any) => { + if (x !== null && typeof x === 'object' && x.id == null) { + x.id = `${config.url}/${uuid.v4()}`; + } + + return Object.assign({ + '@context': [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1', + { Hashtag: 'as:Hashtag' } + ] + }, x); +}; From b3a3238e43dc7d504b266a0c63ae61eaeca93d26 Mon Sep 17 00:00:00 2001 From: mei23 Date: Sat, 25 Aug 2018 13:40:12 +0900 Subject: [PATCH 4/9] =?UTF-8?q?HTTP=20Signature=E6=A4=9C=E8=A8=BC=E5=AF=BE?= =?UTF-8?q?=E8=B1=A1=E3=83=98=E3=83=83=E3=83=80=E3=81=ABDate=E3=81=8C?= =?UTF-8?q?=E5=90=AB=E3=81=BE=E3=82=8C=E3=81=A6=E3=81=AA=E3=81=8F=E3=81=A6?= =?UTF-8?q?=E3=82=82=E8=A8=B1=E5=AE=B9=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/activitypub.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts index d04ffd38f..1007790ca 100644 --- a/src/server/activitypub.ts +++ b/src/server/activitypub.ts @@ -25,7 +25,7 @@ function inbox(ctx: Router.IRouterContext) { ctx.req.headers.authorization = 'Signature ' + ctx.req.headers.signature; try { - signature = httpSignature.parseRequest(ctx.req); + signature = httpSignature.parseRequest(ctx.req, { 'headers': [] }); } catch (e) { ctx.status = 401; return; From ffcb2f755c2d20e62272212905c7d2ca795e4c3d Mon Sep 17 00:00:00 2001 From: mei23 Date: Sat, 25 Aug 2018 14:12:44 +0900 Subject: [PATCH 5/9] Send actor in CreateNote, Announce --- src/remote/activitypub/renderer/announce.ts | 1 + src/remote/activitypub/renderer/create.ts | 16 ++++++++++++---- src/services/note/create.ts | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/remote/activitypub/renderer/announce.ts b/src/remote/activitypub/renderer/announce.ts index 6d5a67b5c..f6276ade0 100644 --- a/src/remote/activitypub/renderer/announce.ts +++ b/src/remote/activitypub/renderer/announce.ts @@ -6,6 +6,7 @@ export default (object: any, note: INote) => { return { id: `${config.url}/notes/${note._id}`, + actor: `${config.url}/users/${note.userId}`, type: 'Announce', published: note.createdAt.toISOString(), to: ['https://www.w3.org/ns/activitystreams#Public'], diff --git a/src/remote/activitypub/renderer/create.ts b/src/remote/activitypub/renderer/create.ts index b8bf98a65..42b36195f 100644 --- a/src/remote/activitypub/renderer/create.ts +++ b/src/remote/activitypub/renderer/create.ts @@ -1,4 +1,12 @@ -export default (object: any) => ({ - type: 'Create', - object -}); +import config from '../../../config'; +import { INote } from '../../../models/note'; + +export default (object: any, note: INote) => { + return { + id: `${config.url}/notes/${note._id}/activity`, + actor: `${config.url}/users/${note.userId}`, + type: 'Create', + published: note.createdAt.toISOString(), + object + }; +}; diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 268bfa5bb..63e355782 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -240,7 +240,7 @@ export default async (user: IUser, data: Option, silent = false) => new Promise< async function renderActivity(data: Option, note: INote) { const content = data.renote && data.text == null ? renderAnnounce(data.renote.uri ? data.renote.uri : `${config.url}/notes/${data.renote._id}`, note) - : renderCreate(await renderNote(note, false)); + : renderCreate(await renderNote(note, false), note); return packAp(content); } From 68a7661f08b851999bb0c7deff1d7553af904fb4 Mon Sep 17 00:00:00 2001 From: mei23 Date: Sat, 25 Aug 2018 14:23:51 +0900 Subject: [PATCH 6/9] =?UTF-8?q?Create=20Note=20activity=20=E3=81=AB?= =?UTF-8?q?=E3=82=82=20to=E3=81=A8cc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/remote/activitypub/renderer/create.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/remote/activitypub/renderer/create.ts b/src/remote/activitypub/renderer/create.ts index 42b36195f..1ee1418fc 100644 --- a/src/remote/activitypub/renderer/create.ts +++ b/src/remote/activitypub/renderer/create.ts @@ -2,11 +2,16 @@ import config from '../../../config'; import { INote } from '../../../models/note'; export default (object: any, note: INote) => { - return { + const activity = { id: `${config.url}/notes/${note._id}/activity`, actor: `${config.url}/users/${note.userId}`, type: 'Create', published: note.createdAt.toISOString(), object - }; + } as any; + + if (object.to) activity.to = object.to; + if (object.cc) activity.cc = object.cc; + + return activity; }; From a39aaf6eb1fb4da308f6a187aec42fce035574af Mon Sep 17 00:00:00 2001 From: mei23 Date: Sat, 25 Aug 2018 14:46:47 +0900 Subject: [PATCH 7/9] Send actor in Undo Follow --- src/remote/activitypub/renderer/undo.ts | 6 +++++- src/services/following/delete.ts | 2 +- src/services/following/requests/cancel.ts | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/remote/activitypub/renderer/undo.ts b/src/remote/activitypub/renderer/undo.ts index 4498409a5..bf90a3f28 100644 --- a/src/remote/activitypub/renderer/undo.ts +++ b/src/remote/activitypub/renderer/undo.ts @@ -1,4 +1,8 @@ -export default (object: any) => ({ +import config from '../../../config'; +import { ILocalUser, IUser } from "../../../models/user"; + +export default (object: any, user: ILocalUser | IUser) => ({ type: 'Undo', + actor: `${config.url}/users/${user._id}`, object }); diff --git a/src/services/following/delete.ts b/src/services/following/delete.ts index 8a9f739bd..7c285e9ea 100644 --- a/src/services/following/delete.ts +++ b/src/services/following/delete.ts @@ -56,7 +56,7 @@ export default async function(follower: IUser, followee: IUser) { } if (isLocalUser(follower) && isRemoteUser(followee)) { - const content = pack(renderUndo(renderFollow(follower, followee))); + const content = pack(renderUndo(renderFollow(follower, followee), follower)); deliver(follower, content, followee.inbox); } } diff --git a/src/services/following/requests/cancel.ts b/src/services/following/requests/cancel.ts index 26e4544d5..9655a95f0 100644 --- a/src/services/following/requests/cancel.ts +++ b/src/services/following/requests/cancel.ts @@ -8,7 +8,7 @@ import { publishUserStream } from '../../../stream'; export default async function(followee: IUser, follower: IUser) { if (isRemoteUser(followee)) { - const content = pack(renderUndo(renderFollow(follower, followee))); + const content = pack(renderUndo(renderFollow(follower, followee), follower)); deliver(follower as ILocalUser, content, followee.inbox); } From ac474f388439ec09cd4429e4ebba9b89365a2b79 Mon Sep 17 00:00:00 2001 From: mei23 Date: Sat, 25 Aug 2018 14:52:35 +0900 Subject: [PATCH 8/9] Send actor in Delete --- src/remote/activitypub/renderer/delete.ts | 6 +++++- src/services/note/delete.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/remote/activitypub/renderer/delete.ts b/src/remote/activitypub/renderer/delete.ts index f468a22e2..2a4e70e25 100644 --- a/src/remote/activitypub/renderer/delete.ts +++ b/src/remote/activitypub/renderer/delete.ts @@ -1,4 +1,8 @@ -export default (object: any) => ({ +import config from '../../../config'; +import { ILocalUser } from "../../../models/user"; + +export default (object: any, user: ILocalUser) => ({ type: 'Delete', + actor: `${config.url}/users/${user._id}`, object }); diff --git a/src/services/note/delete.ts b/src/services/note/delete.ts index d444b13a8..d0e2b12b4 100644 --- a/src/services/note/delete.ts +++ b/src/services/note/delete.ts @@ -32,7 +32,7 @@ export default async function(user: IUser, note: INote) { //#region ローカルの投稿なら削除アクティビティを配送 if (isLocalUser(user)) { - const content = pack(renderDelete(await renderNote(note))); + const content = pack(renderDelete(await renderNote(note), user)); const followings = await Following.find({ followeeId: user._id, From 990a583e5e0d9f96b23e46c5ab9b166226783504 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 25 Aug 2018 16:34:41 +0900 Subject: [PATCH 9/9] 8.12.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e9cb7c8d2..fde0f8280 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "8.11.1", + "version": "8.12.0", "clientVersion": "1.0.8981", "codename": "nighthike", "main": "./built/index.js",