parent
c7106d250c
commit
a1b490afa7
167 changed files with 4440 additions and 1762 deletions
|
|
@ -2,8 +2,8 @@ import { JSDOM } from 'jsdom';
|
|||
import * as debug from 'debug';
|
||||
|
||||
import Resolver from '../../resolver';
|
||||
import Post, { IPost } from '../../../../models/post';
|
||||
import createPost from '../../../../services/post/create';
|
||||
import Note, { INote } from '../../../../models/note';
|
||||
import post from '../../../../services/note/create';
|
||||
import { IRemoteUser } from '../../../../models/user';
|
||||
import resolvePerson from '../../resolve-person';
|
||||
import createImage from './image';
|
||||
|
|
@ -14,14 +14,14 @@ const log = debug('misskey:activitypub');
|
|||
/**
|
||||
* 投稿作成アクティビティを捌きます
|
||||
*/
|
||||
export default async function createNote(resolver: Resolver, actor: IRemoteUser, note, silent = false): Promise<IPost> {
|
||||
export default async function createNote(resolver: Resolver, actor: IRemoteUser, note, silent = false): Promise<INote> {
|
||||
if (typeof note.id !== 'string') {
|
||||
log(`invalid note: ${JSON.stringify(note, null, 2)}`);
|
||||
throw new Error('invalid note');
|
||||
}
|
||||
|
||||
// 既に同じURIを持つものが登録されていないかチェックし、登録されていたらそれを返す
|
||||
const exist = await Post.findOne({ uri: note.id });
|
||||
const exist = await Note.findOne({ uri: note.id });
|
||||
if (exist) {
|
||||
return exist;
|
||||
}
|
||||
|
|
@ -54,12 +54,12 @@ export default async function createNote(resolver: Resolver, actor: IRemoteUser,
|
|||
if ('inReplyTo' in note && note.inReplyTo != null) {
|
||||
// リプライ先の投稿がMisskeyに登録されているか調べる
|
||||
const uri: string = note.inReplyTo.id || note.inReplyTo;
|
||||
const inReplyToPost = uri.startsWith(config.url + '/')
|
||||
? await Post.findOne({ _id: uri.split('/').pop() })
|
||||
: await Post.findOne({ uri });
|
||||
const inReplyToNote = uri.startsWith(config.url + '/')
|
||||
? await Note.findOne({ _id: uri.split('/').pop() })
|
||||
: await Note.findOne({ uri });
|
||||
|
||||
if (inReplyToPost) {
|
||||
reply = inReplyToPost;
|
||||
if (inReplyToNote) {
|
||||
reply = inReplyToNote;
|
||||
} else {
|
||||
// 無かったらフェッチ
|
||||
const inReplyTo = await resolver.resolve(note.inReplyTo) as any;
|
||||
|
|
@ -75,11 +75,11 @@ export default async function createNote(resolver: Resolver, actor: IRemoteUser,
|
|||
|
||||
const { window } = new JSDOM(note.content);
|
||||
|
||||
return await createPost(actor, {
|
||||
return await post(actor, {
|
||||
createdAt: new Date(note.published),
|
||||
media,
|
||||
reply,
|
||||
repost: undefined,
|
||||
renote: undefined,
|
||||
text: window.document.body.textContent,
|
||||
viaMobile: false,
|
||||
geo: undefined,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue