Talk federation (#5534)

This commit is contained in:
MeiMei
2019-10-29 06:01:14 +09:00
committed by syuilo
parent 1e58b3daff
commit 245b08b624
6 changed files with 125 additions and 74 deletions

View File

@@ -23,6 +23,7 @@ import { genId } from '../../../misc/gen-id';
import { fetchMeta } from '../../../misc/fetch-meta';
import { ensure } from '../../../prelude/ensure';
import { getApLock } from '../../../misc/app-lock';
import { createMessage } from '../../../services/messages/create';
const logger = apLogger;
@@ -223,6 +224,13 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s
if (actor.uri) updatePerson(actor.uri);
}
if (note._misskey_talk && visibility === 'specified') {
for (const recipient of visibleUsers) {
await createMessage(actor, recipient, undefined, text || undefined, (files && files.length > 0) ? files[0] : null);
return null;
}
}
return await post(actor, {
createdAt: note.published ? new Date(note.published) : null,
files,

View File

@@ -12,7 +12,7 @@ import { Emoji } from '../../../models/entities/emoji';
import { Poll } from '../../../models/entities/poll';
import { ensure } from '../../../prelude/ensure';
export default async function renderNote(note: Note, dive = true): Promise<any> {
export default async function renderNote(note: Note, dive = true, isTalk = false): Promise<any> {
const promisedFiles: Promise<DriveFile[]> = note.fileIds.length > 0
? DriveFiles.find({ id: In(note.fileIds) })
: Promise.resolve([]);
@@ -145,6 +145,10 @@ export default async function renderNote(note: Note, dive = true): Promise<any>
}))
} : {};
const asTalk = isTalk ? {
_misskey_talk: true
} : {};
return {
id: `${config.url}/notes/${note.id}`,
type: 'Note',
@@ -160,7 +164,8 @@ export default async function renderNote(note: Note, dive = true): Promise<any>
attachment: files.map(renderDocument),
sensitive: note.cw != null || files.some(file => file.isSensitive),
tag,
...asPoll
...asPoll,
...asTalk
};
}

View File

@@ -75,6 +75,7 @@ export interface INote extends IObject {
type: 'Note' | 'Question' | 'Article' | 'Audio' | 'Document' | 'Image' | 'Page' | 'Video';
_misskey_content?: string;
_misskey_quote?: string;
_misskey_talk: boolean;
}
export interface IQuestion extends IObject {