Fix AP inbox Announce (#5641)

This commit is contained in:
MeiMei 2019-12-15 03:32:48 +09:00 committed by syuilo
parent 1d234e10bd
commit e9360ac892
2 changed files with 8 additions and 15 deletions

View File

@ -1,7 +1,7 @@
import Resolver from '../../resolver';
import { IRemoteUser } from '../../../../models/entities/user';
import announceNote from './note';
import { IAnnounce, validPost, getApId } from '../../type';
import { IAnnounce, getApId } from '../../type';
import { apLogger } from '../../logger';
const logger = apLogger;
@ -13,14 +13,7 @@ export default async (actor: IRemoteUser, activity: IAnnounce): Promise<void> =>
const resolver = new Resolver();
const object = await resolver.resolve(activity.object).catch(e => {
logger.error(`Resolution failed: ${e}`);
throw e;
});
const targetUri = getApId(activity.object);
if (validPost.includes(object.type)) {
announceNote(resolver, actor, activity, object);
} else {
logger.warn(`Unknown announce type: ${object.type}`);
}
announceNote(resolver, actor, activity, targetUri);
};

View File

@ -1,7 +1,7 @@
import Resolver from '../../resolver';
import post from '../../../../services/note/create';
import { IRemoteUser, User } from '../../../../models/entities/user';
import { IAnnounce, IObject, getApId, getApIds } from '../../type';
import { IAnnounce, getApId, getApIds } from '../../type';
import { fetchNote, resolveNote } from '../../models/note';
import { resolvePerson } from '../../models/person';
import { apLogger } from '../../logger';
@ -14,7 +14,7 @@ const logger = apLogger;
/**
*
*/
export default async function(resolver: Resolver, actor: IRemoteUser, activity: IAnnounce, note: IObject): Promise<void> {
export default async function(resolver: Resolver, actor: IRemoteUser, activity: IAnnounce, targetUri: string): Promise<void> {
const uri = getApId(activity);
// アナウンサーが凍結されていたらスキップ
@ -38,14 +38,14 @@ export default async function(resolver: Resolver, actor: IRemoteUser, activity:
// Announce対象をresolve
let renote;
try {
renote = await resolveNote(note);
renote = await resolveNote(targetUri);
} catch (e) {
// 対象が4xxならスキップ
if (e.statusCode >= 400 && e.statusCode < 500) {
logger.warn(`Ignored announce target ${note.inReplyTo} - ${e.statusCode}`);
logger.warn(`Ignored announce target ${targetUri} - ${e.statusCode}`);
return;
}
logger.warn(`Error in announce target ${note.inReplyTo} - ${e.statusCode || e}`);
logger.warn(`Error in announce target ${targetUri} - ${e.statusCode || e}`);
throw e;
}