mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-23 02:17:40 -07:00
Fix AP inbox Announce (#5641)
This commit is contained in:
parent
434883be1e
commit
6ecc7f8f25
2 changed files with 8 additions and 15 deletions
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue