@evanp/activitypub-bot 0.24.0 → 0.24.1

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.
@@ -102,7 +102,9 @@ export class ActivityPubClient {
102
102
  assert.equal(typeof obj, 'object')
103
103
  assert.ok(username)
104
104
  assert.equal(typeof username, 'string')
105
- const body = await obj.write()
105
+ const json = await obj.export()
106
+ this.#fixupJson(json)
107
+ const body = JSON.stringify(json)
106
108
  const headers = {
107
109
  date: new Date().toUTCString(),
108
110
  'user-agent': ActivityPubClient.#userAgent,
@@ -174,4 +176,30 @@ export class ActivityPubClient {
174
176
  }
175
177
  }
176
178
  }
179
+
180
+ #fixupJson (json) {
181
+ this.#fixupRelayFollow(json)
182
+ this.#fixupRelayUndoFollow(json)
183
+ }
184
+
185
+ #fixupRelayFollow (json) {
186
+ if (typeof json.type === 'string' &&
187
+ json.type === 'Follow' &&
188
+ typeof json.object === 'string' &&
189
+ json.object === 'as:Public') {
190
+ json.object = 'https://www.w3.org/ns/activitystreams#Public'
191
+ }
192
+ }
193
+
194
+ #fixupRelayUndoFollow (json) {
195
+ if (typeof json.type === 'string' &&
196
+ json.type === 'Undo' &&
197
+ typeof json.object === 'object' &&
198
+ typeof json.object.type === 'string' &&
199
+ json.object.type === 'Follow' &&
200
+ typeof json.object.object === 'string' &&
201
+ json.object.object === 'as:Public') {
202
+ json.object.object = 'https://www.w3.org/ns/activitystreams#Public'
203
+ }
204
+ }
177
205
  }
@@ -20,7 +20,7 @@ export default class RelayClientBot extends Bot {
20
20
 
21
21
  async initialize (context) {
22
22
  super.initialize(context)
23
- this._context.logger.debug(
23
+ this._context.logger.info(
24
24
  { relay: this.#relay, unsubscribe: this.#unsubscribe },
25
25
  'Initialising relay client'
26
26
  )
@@ -36,7 +36,7 @@ export default class RelayClientBot extends Bot {
36
36
  }
37
37
 
38
38
  async #followRelay () {
39
- this._context.logger.debug(
39
+ this._context.logger.info(
40
40
  { relay: this.#relay },
41
41
  'Following relay'
42
42
  )
@@ -45,7 +45,7 @@ export default class RelayClientBot extends Bot {
45
45
  type: 'Follow',
46
46
  object: 'https://www.w3.org/ns/activitystreams#Public'
47
47
  })
48
- this._context.logger.debug(
48
+ this._context.logger.info(
49
49
  { relay: this.#relay, activity: activity.id },
50
50
  'Saving follow for later'
51
51
  )
@@ -54,7 +54,7 @@ export default class RelayClientBot extends Bot {
54
54
 
55
55
  async #unfollowRelay () {
56
56
  const activityId = await this._context.getData(`follow:${this.#relay}`)
57
- this._context.logger.debug(
57
+ this._context.logger.info(
58
58
  { relay: this.#relay, activity: activityId },
59
59
  'Unfollowing relay'
60
60
  )
@@ -67,7 +67,7 @@ export default class RelayClientBot extends Bot {
67
67
  object: 'https://www.w3.org/ns/activitystreams#Public'
68
68
  }
69
69
  })
70
- this._context.logger.debug(
70
+ this._context.logger.info(
71
71
  { relay: this.#relay },
72
72
  'Clearing follow data'
73
73
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanp/activitypub-bot",
3
- "version": "0.24.0",
3
+ "version": "0.24.1",
4
4
  "description": "server-side ActivityPub bot framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",