Fix AP inbox Announce (#5641)
This commit is contained in:
parent
1d234e10bd
commit
e9360ac892
@ -1,7 +1,7 @@
|
|||||||
import Resolver from '../../resolver';
|
import Resolver from '../../resolver';
|
||||||
import { IRemoteUser } from '../../../../models/entities/user';
|
import { IRemoteUser } from '../../../../models/entities/user';
|
||||||
import announceNote from './note';
|
import announceNote from './note';
|
||||||
import { IAnnounce, validPost, getApId } from '../../type';
|
import { IAnnounce, getApId } from '../../type';
|
||||||
import { apLogger } from '../../logger';
|
import { apLogger } from '../../logger';
|
||||||
|
|
||||||
const logger = apLogger;
|
const logger = apLogger;
|
||||||
@ -13,14 +13,7 @@ export default async (actor: IRemoteUser, activity: IAnnounce): Promise<void> =>
|
|||||||
|
|
||||||
const resolver = new Resolver();
|
const resolver = new Resolver();
|
||||||
|
|
||||||
const object = await resolver.resolve(activity.object).catch(e => {
|
const targetUri = getApId(activity.object);
|
||||||
logger.error(`Resolution failed: ${e}`);
|
|
||||||
throw e;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (validPost.includes(object.type)) {
|
announceNote(resolver, actor, activity, targetUri);
|
||||||
announceNote(resolver, actor, activity, object);
|
|
||||||
} else {
|
|
||||||
logger.warn(`Unknown announce type: ${object.type}`);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Resolver from '../../resolver';
|
import Resolver from '../../resolver';
|
||||||
import post from '../../../../services/note/create';
|
import post from '../../../../services/note/create';
|
||||||
import { IRemoteUser, User } from '../../../../models/entities/user';
|
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 { fetchNote, resolveNote } from '../../models/note';
|
||||||
import { resolvePerson } from '../../models/person';
|
import { resolvePerson } from '../../models/person';
|
||||||
import { apLogger } from '../../logger';
|
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);
|
const uri = getApId(activity);
|
||||||
|
|
||||||
// アナウンサーが凍結されていたらスキップ
|
// アナウンサーが凍結されていたらスキップ
|
||||||
@ -38,14 +38,14 @@ export default async function(resolver: Resolver, actor: IRemoteUser, activity:
|
|||||||
// Announce対象をresolve
|
// Announce対象をresolve
|
||||||
let renote;
|
let renote;
|
||||||
try {
|
try {
|
||||||
renote = await resolveNote(note);
|
renote = await resolveNote(targetUri);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// 対象が4xxならスキップ
|
// 対象が4xxならスキップ
|
||||||
if (e.statusCode >= 400 && e.statusCode < 500) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
logger.warn(`Error in announce target ${note.inReplyTo} - ${e.statusCode || e}`);
|
logger.warn(`Error in announce target ${targetUri} - ${e.statusCode || e}`);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user