summaryrefslogtreecommitdiff
path: root/src/remote
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-06-13 05:11:55 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-06-13 05:11:55 +0900
commit1472f0b141cdcb4f21c4db0d5ff3d84a5f8ccb93 (patch)
tree0725ce0c31f7e421576511242c32a9557746a786 /src/remote
parent2.38.0 (diff)
downloadsharkey-1472f0b141cdcb4f21c4db0d5ff3d84a5f8ccb93.tar.gz
sharkey-1472f0b141cdcb4f21c4db0d5ff3d84a5f8ccb93.tar.bz2
sharkey-1472f0b141cdcb4f21c4db0d5ff3d84a5f8ccb93.zip
Fix #1712
Diffstat (limited to 'src/remote')
-rw-r--r--src/remote/activitypub/renderer/hashtag.ts2
-rw-r--r--src/remote/activitypub/renderer/mention.ts9
-rw-r--r--src/remote/activitypub/renderer/note.ts17
3 files changed, 25 insertions, 3 deletions
diff --git a/src/remote/activitypub/renderer/hashtag.ts b/src/remote/activitypub/renderer/hashtag.ts
index 50761c8684..a37ba63532 100644
--- a/src/remote/activitypub/renderer/hashtag.ts
+++ b/src/remote/activitypub/renderer/hashtag.ts
@@ -1,6 +1,6 @@
import config from '../../../config';
-export default tag => ({
+export default (tag: string) => ({
type: 'Hashtag',
href: `${config.url}/tags/${encodeURIComponent(tag)}`,
name: '#' + tag
diff --git a/src/remote/activitypub/renderer/mention.ts b/src/remote/activitypub/renderer/mention.ts
new file mode 100644
index 0000000000..4cba7d6a94
--- /dev/null
+++ b/src/remote/activitypub/renderer/mention.ts
@@ -0,0 +1,9 @@
+export default (mention: {
+ uri: string;
+ username: string;
+ host: string;
+}) => ({
+ type: 'Mention',
+ href: mention.uri,
+ name: `@${mention.username}@${mention.host}`
+});
diff --git a/src/remote/activitypub/renderer/note.ts b/src/remote/activitypub/renderer/note.ts
index a05c12b388..39335a7cca 100644
--- a/src/remote/activitypub/renderer/note.ts
+++ b/src/remote/activitypub/renderer/note.ts
@@ -1,5 +1,6 @@
import renderDocument from './document';
import renderHashtag from './hashtag';
+import renderMention from './mention';
import config from '../../../config';
import DriveFile from '../../../models/drive-file';
import Note, { INote } from '../../../models/note';
@@ -45,6 +46,18 @@ export default async function renderNote(note: INote, dive = true) {
const attributedTo = `${config.url}/users/${user._id}`;
+ const mentions = note.mentionedRemoteUsers && note.mentionedRemoteUsers.length > 0
+ ? note.mentionedRemoteUsers.map(x => x.uri)
+ : [];
+
+ const cc = ['public', 'home', 'followers'].includes(note.visibility)
+ ? [`${attributedTo}/followers`].concat(mentions)
+ : [];
+
+ const hashtagTags = (note.tags || []).map(renderHashtag);
+ const mentionTags = (note.mentionedRemoteUsers || []).map(renderMention);
+ const tag = hashtagTags.concat(mentionTags)
+
return {
id: `${config.url}/notes/${note._id}`,
type: 'Note',
@@ -52,9 +65,9 @@ export default async function renderNote(note: INote, dive = true) {
content: toHtml(note),
published: note.createdAt.toISOString(),
to: 'https://www.w3.org/ns/activitystreams#Public',
- cc: `${attributedTo}/followers`,
+ cc,
inReplyTo,
attachment: (await promisedFiles).map(renderDocument),
- tag: (note.tags || []).map(renderHashtag)
+ tag
};
}