@chatluna/patchbay 0.1.3 → 0.1.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatluna/patchbay",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Cordis 4 patches for Koishi, Satori, Satori adapters and Cordis plugins, wired into yarn, pnpm or npm",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/patchbay.json CHANGED
@@ -17,7 +17,11 @@
17
17
  {
18
18
  "name": "@cordisjs/plugin-http",
19
19
  "version": "1.5.2",
20
- "description": "Use resolveIntercept, which Cordis 4 renamed from resolveConfig"
20
+ "description": "Use resolveIntercept, which Cordis 4 renamed from resolveConfig; merge request headers per name and send the global FormData as multipart",
21
+ "fixes": [
22
+ "ChatLunaLab/v2-mirror#140",
23
+ "ChatLunaLab/v2-mirror#145"
24
+ ]
21
25
  },
22
26
  {
23
27
  "name": "@cordisjs/plugin-loader",
@@ -64,7 +68,10 @@
64
68
  {
65
69
  "name": "koishi-plugin-adapter-onebot",
66
70
  "version": "6.9.5",
67
- "description": "Import Satori directly and inject http, satori and timer"
71
+ "description": "Import Satori directly and inject http, satori and timer; mark friend_recall as a direct channel like private messages",
72
+ "fixes": [
73
+ "ChatLunaLab/v2-mirror#159"
74
+ ]
68
75
  }
69
76
  ],
70
77
  "aliases": {
@@ -1,13 +1,28 @@
1
1
  diff --git a/lib/index.js b/lib/index.js
2
- index 3acbdff..56c9913 100644
2
+ index 3acbdff..0fec2d3 100644
3
3
  --- a/lib/index.js
4
4
  +++ b/lib/index.js
5
- @@ -202,7 +202,7 @@ var Http = class _Http extends Service {
5
+ @@ -202,7 +202,9 @@ var Http = class _Http extends Service {
6
6
  });
7
7
  }
8
8
  resolveConfig(init) {
9
9
  - return this[Service.resolveConfig](this.config, init);
10
- + return { ...this[Service.resolveIntercept](), ...this.config, ...init };
10
+ + // Merge headers per name, so a request's own `headers` (undefined or a Headers instance too) layers over the client's.
11
+ + const configs = [this[Service.resolveIntercept](), this.config, init];
12
+ + return Object.assign({}, ...configs, { headers: Object.fromEntries(configs.flatMap((config) => [...new Headers(config?.headers)])) });
11
13
  }
12
14
  resolveURL(url, config, isWebSocket = false) {
13
15
  try {
16
+ @@ -281,7 +283,11 @@ var Http = class _Http extends Service {
17
+ }
18
+ const response = await this.ctx.waterfall(this, "http/fetch", url, init, config, () => {
19
+ this.ctx.logger("http:request").debug("%C %s", method, url.href);
20
+ - return this.undici.fetch(url, init);
21
+ + // The undici package serializes only its own FormData and would send the global one as "[object FormData]".
22
+ + if (!(init.body instanceof FormData) || init.body instanceof this.undici.FormData) return this.undici.fetch(url, init);
23
+ + const form = new this.undici.FormData();
24
+ + for (const [name, value] of init.body) form.append(name, value);
25
+ + return this.undici.fetch(url, { ...init, body: form });
26
+ }).catch((cause) => {
27
+ this.ctx.logger("http:request").debug("%C %s failed: %o", method, url.href, cause);
28
+ if (_Http.Error.is(cause)) throw cause;
@@ -78,7 +78,7 @@ index 120885c..d5ba237 100644
78
78
  'onebot/message-reactions-updated'(session: Session): void;
79
79
  'onebot/channel-updated'(session: Session): void;
80
80
  diff --git a/lib/index.js b/lib/index.js
81
- index 996a9c8..5b58e18 100644
81
+ index 996a9c8..cf1e9bd 100644
82
82
  --- a/lib/index.js
83
83
  +++ b/lib/index.js
84
84
  @@ -46,10 +46,10 @@ __export(index_exports, {
@@ -108,7 +108,15 @@ index 996a9c8..5b58e18 100644
108
108
  var SafetyLevel = /* @__PURE__ */ ((SafetyLevel2) => {
109
109
  SafetyLevel2[SafetyLevel2["safe"] = 0] = "safe";
110
110
  SafetyLevel2[SafetyLevel2["unknown"] = 1] = "unknown";
111
- @@ -594,7 +594,7 @@ var HttpServer = class extends import_koishi3.Adapter {
111
+ @@ -466,6 +466,7 @@ async function adaptSession(bot, data) {
112
+ session.type = "message-deleted";
113
+ session.subtype = "private";
114
+ session.channelId = `private:${session.userId}`;
115
+ + session.isDirect = true;
116
+ break;
117
+ // from go-cqhttp source code, but not mentioned in official docs
118
+ case "guild_channel_recall":
119
+ @@ -594,7 +595,7 @@ var HttpServer = class extends import_koishi3.Adapter {
112
120
  })(HttpServer || (HttpServer = {}));
113
121
 
114
122
  // src/ws.ts
@@ -117,7 +125,7 @@ index 996a9c8..5b58e18 100644
117
125
  var WsClient = class extends import_koishi4.Adapter.WsClient {
118
126
  static {
119
127
  __name(this, "WsClient");
120
- @@ -734,10 +734,10 @@ function accept(socket, bot) {
128
+ @@ -734,10 +735,10 @@ function accept(socket, bot) {
121
129
  __name(accept, "accept");
122
130
 
123
131
  // src/bot/base.ts
@@ -130,7 +138,7 @@ index 996a9c8..5b58e18 100644
130
138
  var import_node_url = require("node:url");
131
139
  var State = class {
132
140
  constructor(type) {
133
- @@ -830,7 +830,7 @@ var OneBotMessageEncoder = class extends import_koishi5.MessageEncoder {
141
+ @@ -830,7 +831,7 @@ var OneBotMessageEncoder = class extends import_koishi5.MessageEncoder {
134
142
  }
135
143
  async sendFile(attrs) {
136
144
  const src = attrs.src || attrs.url;
@@ -139,7 +147,7 @@ index 996a9c8..5b58e18 100644
139
147
  const file = src.startsWith("file:") ? (0, import_node_url.fileURLToPath)(src) : await this.bot.internal.downloadFile(src);
140
148
  if (this.session.event.channel.type === import_koishi5.Universal.Channel.Type.DIRECT) {
141
149
  await this.bot.internal.uploadPrivateFile(
142
- @@ -977,7 +977,7 @@ var BaseBot2 = class extends import_koishi6.Bot {
150
+ @@ -977,7 +978,7 @@ var BaseBot2 = class extends import_koishi6.Bot {
143
151
  __name(this, "BaseBot");
144
152
  }
145
153
  static MessageEncoder = OneBotMessageEncoder;
@@ -148,7 +156,7 @@ index 996a9c8..5b58e18 100644
148
156
  parent;
149
157
  internal;
150
158
  async createDirectChannel(userId) {
151
- @@ -1112,7 +1112,7 @@ var QQGuildBot = class extends BaseBot2 {
159
+ @@ -1112,7 +1113,7 @@ var QQGuildBot = class extends BaseBot2 {
152
160
  };
153
161
 
154
162
  // src/bot/cqcode.ts