@evanp/activitypub-bot 0.13.7 → 0.13.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,16 +58,16 @@ export class ActivityHandler {
58
58
  const actor = this.#getActor(activity)
59
59
  if (!actor) {
60
60
  this.#logger.warn(
61
- 'Create activity has no actor',
62
- { activity: activity.id }
61
+ { activity: activity.id },
62
+ 'Create activity has no actor'
63
63
  )
64
64
  return
65
65
  }
66
66
  const object = this.#getObject(activity)
67
67
  if (!object) {
68
68
  this.#logger.warn(
69
- 'Create activity has no object',
70
- { activity: activity.id }
69
+ { activity: activity.id },
70
+ 'Create activity has no object'
71
71
  )
72
72
  return
73
73
  }
@@ -79,6 +79,10 @@ export class ActivityHandler {
79
79
  await this.#handleCreateReplies(bot, activity, actor, object)
80
80
  await this.#handleCreateThread(bot, activity, actor, object)
81
81
  if (this.#isMention(bot, object)) {
82
+ this.#logger.debug(
83
+ { username: bot.username, object: object.id },
84
+ 'bot mentioned'
85
+ )
82
86
  await bot.onMention(object, activity)
83
87
  }
84
88
  }
package/lib/bots/ok.js CHANGED
@@ -10,13 +10,30 @@ export default class OKBot extends Bot {
10
10
  }
11
11
 
12
12
  async onMention (object, activity) {
13
+ this._context.logger.debug(
14
+ { object: object.id, activity: activity.id },
15
+ 'bot mentioned'
16
+ )
13
17
  if (!await this.hasSeen(object)) {
18
+ this._context.logger.debug(
19
+ { object: object.id },
20
+ 'not previously seen'
21
+ )
14
22
  const attributedTo =
15
23
  object.attributedTo?.first.id ||
16
24
  activity.actor?.first.id
25
+ this._context.logger.debug(
26
+ { object: object.id, attributedTo: attributedTo },
27
+ 'attributed to'
28
+ )
17
29
  const wf = await this._context.toWebfinger(attributedTo)
18
- this._context.logger.info({ object: object.id, attributedTo, wf }, 'received mention')
19
30
  const content = (wf) ? `@${wf} OK` : 'OK'
31
+ this._context.logger.info({
32
+ object: object.id,
33
+ attributedTo,
34
+ wf,
35
+ content
36
+ }, 'sending reply')
20
37
  const reply = await this._context.sendReply(content, object)
21
38
  this._context.logger.info({
22
39
  reply: reply.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanp/activitypub-bot",
3
- "version": "0.13.7",
3
+ "version": "0.13.9",
4
4
  "description": "server-side ActivityPub bot framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",