Create ActivityでattributedToの補完とaudienceのコピーを行うように (#5873)
* attributedTo * Create * copy audiences between activity <=> object * やっぱり匿名GETのpublicは必要 * fix
This commit is contained in:
parent
b2859bcd2a
commit
aa573c0063
3 changed files with 23 additions and 12 deletions
|
|
@ -3,6 +3,7 @@ import { IRemoteUser } from '../../../../models/entities/user';
|
|||
import createNote from './note';
|
||||
import { ICreate, getApId, validPost } from '../../type';
|
||||
import { apLogger } from '../../logger';
|
||||
import { toArray, concat, unique } from '../../../../prelude/array';
|
||||
|
||||
const logger = apLogger;
|
||||
|
||||
|
|
@ -11,6 +12,22 @@ export default async (actor: IRemoteUser, activity: ICreate): Promise<void> => {
|
|||
|
||||
logger.info(`Create: ${uri}`);
|
||||
|
||||
// copy audiences between activity <=> object.
|
||||
if (typeof activity.object === 'object') {
|
||||
const to = unique(concat([toArray(activity.to), toArray(activity.object.to)]));
|
||||
const cc = unique(concat([toArray(activity.cc), toArray(activity.object.cc)]));
|
||||
|
||||
activity.to = to;
|
||||
activity.cc = cc;
|
||||
activity.object.to = to;
|
||||
activity.object.cc = cc;
|
||||
}
|
||||
|
||||
// If there is no attributedTo, use Activity actor.
|
||||
if (typeof activity.object === 'object' && !activity.object.attributedTo) {
|
||||
activity.object.attributedTo = activity.actor;
|
||||
}
|
||||
|
||||
const resolver = new Resolver();
|
||||
|
||||
const object = await resolver.resolve(activity.object).catch(e => {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export default async function(resolver: Resolver, actor: IRemoteUser, note: IObj
|
|||
try {
|
||||
const exist = await fetchNote(note);
|
||||
if (exist == null) {
|
||||
await createNote(note, resolver, silent, activity);
|
||||
await createNote(note, resolver, silent);
|
||||
}
|
||||
} finally {
|
||||
unlock();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue