summaryrefslogtreecommitdiff
path: root/src/remote
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-23 15:27:01 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-23 15:27:01 +0900
commit02bb99ac029e8fc12aec384717341f603052d7c0 (patch)
tree1dcce6bdb5f329f58e8e6772c6717f49d658863b /src/remote
parentサーバーのバージョンとクライアントのバージョンを分... (diff)
downloadmisskey-02bb99ac029e8fc12aec384717341f603052d7c0.tar.gz
misskey-02bb99ac029e8fc12aec384717341f603052d7c0.tar.bz2
misskey-02bb99ac029e8fc12aec384717341f603052d7c0.zip
他のMisskeyインスタンスにリアクション情報を伝えるように
Diffstat (limited to 'src/remote')
-rw-r--r--src/remote/activitypub/kernel/like.ts12
-rw-r--r--src/remote/activitypub/renderer/like.ts5
-rw-r--r--src/remote/activitypub/type.ts1
3 files changed, 15 insertions, 3 deletions
diff --git a/src/remote/activitypub/kernel/like.ts b/src/remote/activitypub/kernel/like.ts
index fc5d0a2f61..17ec73f12b 100644
--- a/src/remote/activitypub/kernel/like.ts
+++ b/src/remote/activitypub/kernel/like.ts
@@ -3,6 +3,7 @@ import Note from '../../../models/note';
import { IRemoteUser } from '../../../models/user';
import { ILike } from '../type';
import create from '../../../services/note/reaction/create';
+import { validateReaction } from '../../../models/note-reaction';
export default async (actor: IRemoteUser, activity: ILike) => {
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
@@ -17,5 +18,14 @@ export default async (actor: IRemoteUser, activity: ILike) => {
throw new Error();
}
- await create(actor, note, 'pudding');
+ let reaction = 'pudding';
+
+ // 他のMisskeyインスタンスからのリアクション
+ if (activity._misskey_reaction) {
+ if (validateReaction.ok(activity._misskey_reaction)) {
+ reaction = activity._misskey_reaction;
+ }
+ }
+
+ await create(actor, note, reaction);
};
diff --git a/src/remote/activitypub/renderer/like.ts b/src/remote/activitypub/renderer/like.ts
index 061a10ba84..33e1341a20 100644
--- a/src/remote/activitypub/renderer/like.ts
+++ b/src/remote/activitypub/renderer/like.ts
@@ -1,8 +1,9 @@
import config from '../../../config';
import { ILocalUser } from '../../../models/user';
-export default (user: ILocalUser, note) => ({
+export default (user: ILocalUser, note, reaction: string) => ({
type: 'Like',
actor: `${config.url}/users/${user._id}`,
- object: note.uri ? note.uri : `${config.url}/notes/${note._id}`
+ object: note.uri ? note.uri : `${config.url}/notes/${note._id}`,
+ _misskey_reaction: reaction
});
diff --git a/src/remote/activitypub/type.ts b/src/remote/activitypub/type.ts
index 08e5493dd4..6018ac29c4 100644
--- a/src/remote/activitypub/type.ts
+++ b/src/remote/activitypub/type.ts
@@ -82,6 +82,7 @@ export interface IAccept extends IActivity {
export interface ILike extends IActivity {
type: 'Like';
+ _misskey_reaction: string;
}
export interface IAnnounce extends IActivity {