summaryrefslogtreecommitdiff
path: root/src/remote
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-22 10:44:17 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-22 10:44:17 +0900
commit20e77196f28178c869402985761bd4c2fa74bf0a (patch)
treebeb333d0a01cf6752bdcc6028c82ce63f579f1f1 /src/remote
parentFix #1531 (diff)
downloadsharkey-20e77196f28178c869402985761bd4c2fa74bf0a.tar.gz
sharkey-20e77196f28178c869402985761bd4c2fa74bf0a.tar.bz2
sharkey-20e77196f28178c869402985761bd4c2fa74bf0a.zip
AP: 投票をレンダリング
Diffstat (limited to 'src/remote')
-rw-r--r--src/remote/activitypub/kernel/delete/note.ts1
-rw-r--r--src/remote/activitypub/misc/get-note-html.ts18
-rw-r--r--src/remote/activitypub/renderer/note.ts3
3 files changed, 20 insertions, 2 deletions
diff --git a/src/remote/activitypub/kernel/delete/note.ts b/src/remote/activitypub/kernel/delete/note.ts
index 64c342d39b..b2868f69a3 100644
--- a/src/remote/activitypub/kernel/delete/note.ts
+++ b/src/remote/activitypub/kernel/delete/note.ts
@@ -22,7 +22,6 @@ export default async function(actor: IRemoteUser, uri: string): Promise<void> {
$set: {
deletedAt: new Date(),
text: null,
- textHtml: null,
mediaIds: [],
poll: null
}
diff --git a/src/remote/activitypub/misc/get-note-html.ts b/src/remote/activitypub/misc/get-note-html.ts
new file mode 100644
index 0000000000..a63059a38d
--- /dev/null
+++ b/src/remote/activitypub/misc/get-note-html.ts
@@ -0,0 +1,18 @@
+import { INote } from "../../../models/note";
+import toHtml from '../../../text/html';
+import parse from '../../../text/parse';
+import config from '../../../config';
+
+export default function(note: INote) {
+ if (note.text == null) return null;
+
+ let html = toHtml(parse(note.text));
+
+ if (note.poll != null) {
+ const url = `${config.url}/notes/${note._id}`;
+ // TODO: i18n
+ html += `<p>【投票】<br />${url}</p>`;
+ }
+
+ return html;
+}
diff --git a/src/remote/activitypub/renderer/note.ts b/src/remote/activitypub/renderer/note.ts
index c364b13249..a05c12b388 100644
--- a/src/remote/activitypub/renderer/note.ts
+++ b/src/remote/activitypub/renderer/note.ts
@@ -4,6 +4,7 @@ import config from '../../../config';
import DriveFile from '../../../models/drive-file';
import Note, { INote } from '../../../models/note';
import User from '../../../models/user';
+import toHtml from '../misc/get-note-html';
export default async function renderNote(note: INote, dive = true) {
const promisedFiles = note.mediaIds
@@ -48,7 +49,7 @@ export default async function renderNote(note: INote, dive = true) {
id: `${config.url}/notes/${note._id}`,
type: 'Note',
attributedTo,
- content: note.textHtml,
+ content: toHtml(note),
published: note.createdAt.toISOString(),
to: 'https://www.w3.org/ns/activitystreams#Public',
cc: `${attributedTo}/followers`,