Skip to content

Commit

Permalink
fix: 修复各模块获取服务端消息时,未能获取最新请求导致解密异常的问题。(#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpyer committed Jul 26, 2024
1 parent 225c205 commit 4c26a74
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/Core/Http/ServerRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ServerRequest implements ServerRequestInterface
.withQueryParams(parse(url, true).query || {});

if (body) {
this.parsedBody = {};
this.withBody(body);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/OfficialAccount/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Server extends ServerInterface
let message = await this.getRequestMessage(this.request);

if (this.encryptor && query['msg_signature']) {
this.prepend(this.decryptRequestMessage(query));
this.prepend(this.decryptRequestMessage());
}

let response = await this.handle(new Response(200, {}, 'success'), message);
Expand Down Expand Up @@ -78,8 +78,9 @@ class Server extends ServerInterface
return Message.createFromRequest(request || this.request);
}

protected decryptRequestMessage(query: Record<string, any>): ServerHandlerClosure<Message> {
protected decryptRequestMessage(): ServerHandlerClosure<Message> {
return async (message: Message, next: ServerHandlerClosure<Message>) => {
let query = this.request.getQueryParams();
message = await this.decryptMessage(
message,
this.encryptor,
Expand Down
5 changes: 3 additions & 2 deletions src/OpenPlatform/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Server extends ServerInterface
let message = await this.getRequestMessage(this.request);

if (this.encryptor && query['msg_signature']) {
this.prepend(this.decryptRequestMessage(query));
this.prepend(this.decryptRequestMessage());
}

let response = await this.handle(new Response(200, {}, 'success'), message);
Expand Down Expand Up @@ -115,8 +115,9 @@ class Server extends ServerInterface
})
}

protected decryptRequestMessage(query: Record<string, any>): ServerHandlerClosure<Message> {
protected decryptRequestMessage(): ServerHandlerClosure<Message> {
return async (message: Message, next: ServerHandlerClosure<Message>) => {
let query = this.request.getQueryParams();
message = await this.decryptMessage(
message,
this.encryptor,
Expand Down
5 changes: 3 additions & 2 deletions src/OpenWork/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Server extends ServerInterface
let message = await this.getRequestMessage(this.request);

if (this.encryptor && query['msg_signature']) {
this.prepend(this.decryptRequestMessage(query));
this.prepend(this.decryptRequestMessage());
}

let response = await this.handle(new Response(200, {}, 'success'), message);
Expand Down Expand Up @@ -210,8 +210,9 @@ class Server extends ServerInterface
return Message.createFromRequest(request ?? this.request);
}

protected decryptRequestMessage(query: Record<string, any>): ServerHandlerClosure<Message> {
protected decryptRequestMessage(): ServerHandlerClosure<Message> {
return async (message: Message, next: ServerHandlerClosure<Message>) => {
let query = this.request.getQueryParams();
message = await this.decryptMessage(
message,
this.encryptor,
Expand Down
5 changes: 3 additions & 2 deletions src/Work/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Server extends ServerInterface
let message = await this.getRequestMessage(this.request);

if (this.encryptor && query['msg_signature']) {
this.prepend(this.decryptRequestMessage(query));
this.prepend(this.decryptRequestMessage());
}

let response = await this.handle(new Response(200, {}, 'SUCCESS'), message);
Expand Down Expand Up @@ -185,8 +185,9 @@ class Server extends ServerInterface
};
}

protected decryptRequestMessage(query: Record<string, any>): ServerHandlerClosure {
protected decryptRequestMessage(): ServerHandlerClosure {
return async (message: Message, next: ServerHandlerClosure) => {
let query = this.request.getQueryParams();
message = await this.decryptMessage(
message,
this.encryptor,
Expand Down

0 comments on commit 4c26a74

Please sign in to comment.