fix(discord): authorize stop actions explicitly
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
This commit is contained in:
@@ -688,7 +688,7 @@ export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewa
|
|||||||
@MessageBody() envelope: DiscordIngressEnvelope,
|
@MessageBody() envelope: DiscordIngressEnvelope,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!client.data.discordService) return;
|
if (!client.data.discordService) return;
|
||||||
const ingress = this.resolveDiscordIngress(client, envelope, 'approve');
|
const ingress = this.resolveDiscordIngress(client, envelope, 'stop');
|
||||||
const actionParts = ingress?.content.match(/^\/stop\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)$/i);
|
const actionParts = ingress?.content.match(/^\/stop\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)$/i);
|
||||||
const serviceUserId = process.env['DISCORD_SERVICE_USER_ID'];
|
const serviceUserId = process.env['DISCORD_SERVICE_USER_ID'];
|
||||||
if (!ingress || !actionParts || !serviceUserId || !this.runtimeRegistry) return;
|
if (!ingress || !actionParts || !serviceUserId || !this.runtimeRegistry) return;
|
||||||
@@ -697,7 +697,7 @@ export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewa
|
|||||||
ingress.guildId,
|
ingress.guildId,
|
||||||
ingress.channelId,
|
ingress.channelId,
|
||||||
ingress.userId,
|
ingress.userId,
|
||||||
'approve',
|
'stop',
|
||||||
);
|
);
|
||||||
if (!binding) return;
|
if (!binding) return;
|
||||||
|
|
||||||
@@ -721,7 +721,7 @@ export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewa
|
|||||||
private resolveDiscordIngress(
|
private resolveDiscordIngress(
|
||||||
client: Socket,
|
client: Socket,
|
||||||
envelope: DiscordIngressEnvelope,
|
envelope: DiscordIngressEnvelope,
|
||||||
operation: 'send' | 'approve' = 'send',
|
operation: 'send' | 'approve' | 'stop' = 'send',
|
||||||
): DiscordIngressPayload | null {
|
): DiscordIngressPayload | null {
|
||||||
const payload = verifyDiscordIngressEnvelope(
|
const payload = verifyDiscordIngressEnvelope(
|
||||||
envelope,
|
envelope,
|
||||||
|
|||||||
Reference in New Issue
Block a user