diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2018-06-17 16:02:21 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-17 16:02:21 +0900 |
| commit | 44cd1e9223e7c7d4804794b5f61b0b7f927de61d (patch) | |
| tree | a63210a9784da7928662f4fb5e2cc467f1941951 /src | |
| parent | Merge pull request #1722 from rinsuki/fix/1700 (diff) | |
| parent | fix #1726 (diff) | |
| download | sharkey-44cd1e9223e7c7d4804794b5f61b0b7f927de61d.tar.gz sharkey-44cd1e9223e7c7d4804794b5f61b0b7f927de61d.tar.bz2 sharkey-44cd1e9223e7c7d4804794b5f61b0b7f927de61d.zip | |
Merge pull request #1728 from rinsuki/fix/1726
fix #1726
Diffstat (limited to 'src')
| -rw-r--r-- | src/remote/activitypub/misc/get-note-html.ts | 2 | ||||
| -rw-r--r-- | src/text/html.ts | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/remote/activitypub/misc/get-note-html.ts b/src/remote/activitypub/misc/get-note-html.ts index 5bca4eed62..33dd381689 100644 --- a/src/remote/activitypub/misc/get-note-html.ts +++ b/src/remote/activitypub/misc/get-note-html.ts @@ -6,7 +6,7 @@ import config from '../../../config'; export default function(note: INote) { if (note.text == null) return null; - let html = toHtml(parse(note.text)); + let html = toHtml(parse(note.text), note.mentionedRemoteUsers); if (note.poll != null) { const url = `${config.url}/notes/${note._id}`; diff --git a/src/text/html.ts b/src/text/html.ts index 70b341689a..a51406ca85 100644 --- a/src/text/html.ts +++ b/src/text/html.ts @@ -1,8 +1,9 @@ import { lib as emojilib } from 'emojilib'; import { JSDOM } from 'jsdom'; import config from '../config'; +import { INote } from '../models/note'; -const handlers = { +const handlers: {[key: string]: (window: any, token: any, mentionedRemoteUsers: INote["mentionedRemoteUsers"]) => void} = { bold({ document }, { bold }) { const b = document.createElement('b'); b.textContent = bold; @@ -44,9 +45,10 @@ const handlers = { document.body.appendChild(a); }, - mention({ document }, { content }) { + mention({ document }, { content, username, host }, mentionedRemoteUsers) { const a = document.createElement('a'); - a.href = `${config.url}/${content}`; + const remoteUserInfo = mentionedRemoteUsers.find(remoteUser => remoteUser.username === username && remoteUser.host === host); + a.href = remoteUserInfo ? remoteUserInfo.uri : `${config.url}/${content}`; a.textContent = content; document.body.appendChild(a); }, @@ -88,11 +90,11 @@ const handlers = { } }; -export default tokens => { +export default (tokens, mentionedRemoteUsers: INote["mentionedRemoteUsers"] = []) => { const { window } = new JSDOM(''); for (const token of tokens) { - handlers[token.type](window, token); + handlers[token.type](window, token, mentionedRemoteUsers); } return `<p>${window.document.body.innerHTML}</p>`; |