This commit is contained in:
syuilo 2018-04-05 23:19:47 +09:00
parent 5f8ab58446
commit 30bd467b71
2 changed files with 24 additions and 22 deletions

View File

@ -31,7 +31,7 @@ export default async (user: IUser, content: {
visibility?: string; visibility?: string;
uri?: string; uri?: string;
app?: IApp; app?: IApp;
}) => new Promise<IPost>(async (res, rej) => { }, silent = false) => new Promise<IPost>(async (res, rej) => {
if (content.createdAt == null) content.createdAt = new Date(); if (content.createdAt == null) content.createdAt = new Date();
if (content.visibility == null) content.visibility = 'public'; if (content.visibility == null) content.visibility = 'public';
@ -120,6 +120,7 @@ export default async (user: IUser, content: {
_id: false _id: false
}); });
if (!silent) {
const note = await renderNote(user, post); const note = await renderNote(user, post);
const content = renderCreate(note); const content = renderCreate(note);
content['@context'] = context; content['@context'] = context;
@ -141,6 +142,7 @@ export default async (user: IUser, content: {
} }
})); }));
} }
}
// チャンネルへの投稿 // チャンネルへの投稿
/* TODO /* TODO

View File

@ -58,7 +58,7 @@ async function createImage(resolver: Resolver, actor: IRemoteUser, image) {
return await uploadFromUrl(image.url, actor); return await uploadFromUrl(image.url, actor);
} }
async function createNote(resolver: Resolver, actor: IRemoteUser, note) { async function createNote(resolver: Resolver, actor: IRemoteUser, note, silent = false) {
if ( if (
('attributedTo' in note && actor.account.uri !== note.attributedTo) || ('attributedTo' in note && actor.account.uri !== note.attributedTo) ||
typeof note.id !== 'string' typeof note.id !== 'string'
@ -86,7 +86,7 @@ async function createNote(resolver: Resolver, actor: IRemoteUser, note) {
const inReplyTo = await resolver.resolve(note.inReplyTo) as any; const inReplyTo = await resolver.resolve(note.inReplyTo) as any;
const actor = await resolvePerson(inReplyTo.attributedTo); const actor = await resolvePerson(inReplyTo.attributedTo);
if (isRemoteUser(actor)) { if (isRemoteUser(actor)) {
reply = await createNote(resolver, actor, inReplyTo); reply = await createNote(resolver, actor, inReplyTo, true);
} }
} }
} }
@ -102,5 +102,5 @@ async function createNote(resolver: Resolver, actor: IRemoteUser, note) {
viaMobile: false, viaMobile: false,
geo: undefined, geo: undefined,
uri: note.id uri: note.id
}); }, silent);
} }