Skip to content

Commit

Permalink
chore(backend): ノートを受信した際に遅延時間をログ出力するように
Browse files Browse the repository at this point in the history
  • Loading branch information
4ster1sk committed Dec 27, 2024
1 parent 540864f commit 383fc54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/backend/src/core/activitypub/ApInboxService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export class ApInboxService {
const exist = await this.apNoteService.fetchNote(note);
if (exist) return 'skip: note exists';

await this.apNoteService.createNote(note, actor, resolver, silent);
await this.apNoteService.createNote(note, actor, resolver, silent, true);
return 'ok';
} catch (err) {
if (err instanceof StatusError && !err.isRetryable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class ApNoteService {
* Noteを作成します。
*/
@bindThis
public async createNote(value: string | IObject, actor?: MiRemoteUser, resolver?: Resolver, silent = false): Promise<MiNote | null> {
public async createNote(value: string | IObject, actor?: MiRemoteUser, resolver?: Resolver, silent = false, checkDelay = false): Promise<MiNote | null> {
// eslint-disable-next-line no-param-reassign
if (resolver == null) resolver = this.apResolverService.createResolver();

Expand Down Expand Up @@ -316,6 +316,11 @@ export class ApNoteService {

const apEmojis = emojis.map(emoji => emoji.name);

if (checkDelay && note.published) {
const delay = Date.now() - new Date(note.published).getTime();
this.logger.info(`Note Received delay: ${delay}ms, host: ${actor.host}`);
}

try {
return await this.noteCreateService.create(actor, {
createdAt: note.published ? new Date(note.published) : null,
Expand Down

0 comments on commit 383fc54

Please sign in to comment.