wip
This commit is contained in:
parent
08beb45935
commit
536277122d
13 changed files with 7 additions and 0 deletions
45
src/remote/activitypub/kernel/announce/note.ts
Normal file
45
src/remote/activitypub/kernel/announce/note.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import * as debug from 'debug';
|
||||
|
||||
import Resolver from '../../resolver';
|
||||
import post from '../../../../services/note/create';
|
||||
import { IRemoteUser } from '../../../../models/user';
|
||||
import { IAnnounce, INote } from '../../type';
|
||||
import { fetchNote, resolveNote } from '../../objects/note';
|
||||
|
||||
const log = debug('misskey:activitypub');
|
||||
|
||||
/**
|
||||
* アナウンスアクティビティを捌きます
|
||||
*/
|
||||
export default async function(resolver: Resolver, actor: IRemoteUser, activity: IAnnounce, note: INote): Promise<void> {
|
||||
const uri = activity.id || activity;
|
||||
|
||||
if (typeof uri !== 'string') {
|
||||
throw new Error('invalid announce');
|
||||
}
|
||||
|
||||
// 既に同じURIを持つものが登録されていないかチェック
|
||||
const exist = await fetchNote(uri);
|
||||
if (exist) {
|
||||
return;
|
||||
}
|
||||
|
||||
const renote = await resolveNote(note);
|
||||
|
||||
log(`Creating the (Re)Note: ${uri}`);
|
||||
|
||||
//#region Visibility
|
||||
let visibility = 'public';
|
||||
if (!activity.to.includes('https://www.w3.org/ns/activitystreams#Public')) visibility = 'unlisted';
|
||||
if (activity.cc.length == 0) visibility = 'private';
|
||||
// TODO
|
||||
if (visibility != 'public') throw new Error('unspported visibility');
|
||||
//#endergion
|
||||
|
||||
await post(actor, {
|
||||
createdAt: new Date(activity.published),
|
||||
renote,
|
||||
visibility,
|
||||
uri
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue