mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-03-29 02:19:51 +00:00
@@ -12,6 +12,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to
|
||||
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased] - 2025-XX-XX
|
||||
|
||||
### Added
|
||||
|
||||
- Implemented `/ping` for
|
||||
[synapse-http-antispam](https://the-draupnir-project.github.io/draupnir-documentation/bot/synapse-http-antispam).
|
||||
It is now possible to check if synapse is misconfigured by searching for
|
||||
`Successfully pinged antispam server with request ID` in any worker log.
|
||||
|
||||
## [v2.3.1] - 2025-05-29
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -46,6 +46,7 @@ modules:
|
||||
config:
|
||||
base_url: http://host.docker.internal:8082/api/1/spam_check
|
||||
authorization: DEFAULT
|
||||
do_ping: true
|
||||
enabled_callbacks:
|
||||
- user_may_invite
|
||||
- user_may_join_room
|
||||
|
||||
37
src/webapis/SynapseHTTPAntispam/PingEndpoint.ts
Normal file
37
src/webapis/SynapseHTTPAntispam/PingEndpoint.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
// SPDX-FileCopyrightText: 2025 Gnuxie <Gnuxie@protonmail.com>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// SPDX-FileAttributionText: <text>
|
||||
// This modified file incorporates work from Draupnir
|
||||
// https://github.com/the-draupnir-project/Draupnir
|
||||
// </text>
|
||||
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import { Request, Response } from "express";
|
||||
import { isError, Logger, Value } from "matrix-protection-suite";
|
||||
|
||||
const log = new Logger("PingEndpoint");
|
||||
|
||||
const PingBody = Type.Object({
|
||||
id: Type.Unknown(),
|
||||
});
|
||||
|
||||
export function handleHttpAntispamPing(
|
||||
request: Request,
|
||||
response: Response
|
||||
): void {
|
||||
const decodedBody = Value.Decode(PingBody, request.body);
|
||||
if (isError(decodedBody)) {
|
||||
log.error("Error decoding request body:", decodedBody.error);
|
||||
response.status(400).send({
|
||||
errcode: "M_INVALID_PARAM",
|
||||
error: "Error decoding request body",
|
||||
});
|
||||
return;
|
||||
}
|
||||
response.status(200).send({
|
||||
id: decodedBody.ok.id,
|
||||
status: "ok",
|
||||
});
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
CheckEventForSpamEndpoint,
|
||||
CheckEventForSpamListenerArguments,
|
||||
} from "./CheckEventForSpamEndpoint";
|
||||
import { handleHttpAntispamPing } from "./PingEndpoint";
|
||||
|
||||
const SPAM_CHECK_PREFIX = "/api/1/spam_check";
|
||||
const AUTHORIZATION = new RegExp("Bearer (.*)");
|
||||
@@ -81,5 +82,9 @@ export class SynapseHttpAntispam {
|
||||
);
|
||||
})
|
||||
);
|
||||
webController.post(
|
||||
`${SPAM_CHECK_PREFIX}/ping`,
|
||||
makeAuthenticatedEndpointHandler(this.secret, handleHttpAntispamPing)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user