AP: 投票をレンダリング

This commit is contained in:
syuilo 2018-04-22 10:44:17 +09:00
parent 45dcfc8a00
commit 20e77196f2
10 changed files with 21 additions and 22 deletions

View file

@ -36,7 +36,7 @@
</p> </p>
<div class="text"> <div class="text">
<a class="reply" v-if="p.reply">%fa:reply%</a> <a class="reply" v-if="p.reply">%fa:reply%</a>
<mk-note-html v-if="p.textHtml" :text="p.text" :i="os.i" :class="$style.text"/> <mk-note-html v-if="p.text" :text="p.text" :i="os.i" :class="$style.text"/>
<a class="rp" v-if="p.renote">RP:</a> <a class="rp" v-if="p.renote">RP:</a>
</div> </div>
<div class="media" v-if="p.media.length > 0"> <div class="media" v-if="p.media.length > 0">

View file

@ -29,12 +29,6 @@ props:
desc: desc:
ja: "投稿の本文 (ローカルの場合Markdown風のフォーマット)" ja: "投稿の本文 (ローカルの場合Markdown風のフォーマット)"
en: "The text of this note (in Markdown like format if local)" en: "The text of this note (in Markdown like format if local)"
- name: "textHtml"
type: "string"
optional: true
desc:
ja: "投稿の本文 (HTML) (投稿時は無視)"
en: "The text of this note (in HTML. Ignored when posting.)"
- name: "mediaIds" - name: "mediaIds"
type: "id(DriveFile)[]" type: "id(DriveFile)[]"
optional: true optional: true

View file

@ -29,12 +29,6 @@ props:
desc: desc:
ja: "投稿の本文 (ローカルの場合Markdown風のフォーマット)" ja: "投稿の本文 (ローカルの場合Markdown風のフォーマット)"
en: "The text of this note (in Markdown like format if local)" en: "The text of this note (in Markdown like format if local)"
- name: "textHtml"
type: "string"
optional: true
desc:
ja: "投稿の本文 (HTML) (投稿時は無視)"
en: "The text of this note (in HTML. Ignored when posting.)"
- name: "mediaIds" - name: "mediaIds"
type: "id(DriveFile)[]" type: "id(DriveFile)[]"
optional: true optional: true

View file

@ -12,7 +12,6 @@ export interface IMessagingMessage {
_id: mongo.ObjectID; _id: mongo.ObjectID;
createdAt: Date; createdAt: Date;
text: string; text: string;
textHtml: string;
userId: mongo.ObjectID; userId: mongo.ObjectID;
recipientId: mongo.ObjectID; recipientId: mongo.ObjectID;
isRead: boolean; isRead: boolean;

View file

@ -38,7 +38,6 @@ export type INote = {
poll: any; // todo poll: any; // todo
text: string; text: string;
tags: string[]; tags: string[];
textHtml: string;
cw: string; cw: string;
userId: mongo.ObjectID; userId: mongo.ObjectID;
appId: mongo.ObjectID; appId: mongo.ObjectID;

View file

@ -22,7 +22,6 @@ export default async function(actor: IRemoteUser, uri: string): Promise<void> {
$set: { $set: {
deletedAt: new Date(), deletedAt: new Date(),
text: null, text: null,
textHtml: null,
mediaIds: [], mediaIds: [],
poll: null poll: null
} }

View file

@ -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;
}

View file

@ -4,6 +4,7 @@ import config from '../../../config';
import DriveFile from '../../../models/drive-file'; import DriveFile from '../../../models/drive-file';
import Note, { INote } from '../../../models/note'; import Note, { INote } from '../../../models/note';
import User from '../../../models/user'; import User from '../../../models/user';
import toHtml from '../misc/get-note-html';
export default async function renderNote(note: INote, dive = true) { export default async function renderNote(note: INote, dive = true) {
const promisedFiles = note.mediaIds const promisedFiles = note.mediaIds
@ -48,7 +49,7 @@ export default async function renderNote(note: INote, dive = true) {
id: `${config.url}/notes/${note._id}`, id: `${config.url}/notes/${note._id}`,
type: 'Note', type: 'Note',
attributedTo, attributedTo,
content: note.textHtml, content: toHtml(note),
published: note.createdAt.toISOString(), published: note.createdAt.toISOString(),
to: 'https://www.w3.org/ns/activitystreams#Public', to: 'https://www.w3.org/ns/activitystreams#Public',
cc: `${attributedTo}/followers`, cc: `${attributedTo}/followers`,

View file

@ -12,8 +12,6 @@ import { pack } from '../../../../../models/messaging-message';
import publishUserStream from '../../../../../publishers/stream'; import publishUserStream from '../../../../../publishers/stream';
import { publishMessagingStream, publishMessagingIndexStream } from '../../../../../publishers/stream'; import { publishMessagingStream, publishMessagingIndexStream } from '../../../../../publishers/stream';
import pushSw from '../../../../../publishers/push-sw'; import pushSw from '../../../../../publishers/push-sw';
import html from '../../../../../text/html';
import parse from '../../../../../text/parse';
import config from '../../../../../config'; import config from '../../../../../config';
/** /**
@ -77,7 +75,6 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
fileId: file ? file._id : undefined, fileId: file ? file._id : undefined,
recipientId: recipient._id, recipientId: recipient._id,
text: text ? text : undefined, text: text ? text : undefined,
textHtml: text ? html(parse(text)) : undefined,
userId: user._id, userId: user._id,
isRead: false isRead: false
}); });

View file

@ -15,7 +15,6 @@ import Mute from '../../models/mute';
import pushSw from '../../publishers/push-sw'; import pushSw from '../../publishers/push-sw';
import event from '../../publishers/stream'; import event from '../../publishers/stream';
import parse from '../../text/parse'; import parse from '../../text/parse';
import html from '../../text/html';
import { IApp } from '../../models/app'; import { IApp } from '../../models/app';
export default async (user: IUser, data: { export default async (user: IUser, data: {
@ -63,7 +62,6 @@ export default async (user: IUser, data: {
replyId: data.reply ? data.reply._id : null, replyId: data.reply ? data.reply._id : null,
renoteId: data.renote ? data.renote._id : null, renoteId: data.renote ? data.renote._id : null,
text: data.text, text: data.text,
textHtml: tokens === null ? null : html(tokens),
poll: data.poll, poll: data.poll,
cw: data.cw, cw: data.cw,
tags, tags,