Files
oneuptime/Common/Server/API/StatusPageSubscriberAPI.ts
Simon Larsen 7f59e62b5d Refactor Slack Markdown Conversion and Update Slack Notification Logic
- Renamed `convertMarkdownToSlack` to `convertMarkdownToSlackRichText` for clarity in Slack utility.
- Updated various components and worker jobs to utilize the new Slack markdown conversion method.
- Removed unused test webhook functionality from the Slack subscribers page.
- Improved formatting of Slack messages in notification jobs to enhance readability.
- Cleaned up code by removing unnecessary fragments and ensuring consistent formatting.
- Enhanced error handling and user feedback for Slack webhook testing.
2025-06-04 19:52:59 +01:00

49 lines
1.3 KiB
TypeScript

import StatusPageSubscriberService, {
Service as StatusPageSubscriberServiceType,
} from "../Services/StatusPageSubscriberService";
import {
ExpressRequest,
ExpressResponse,
NextFunction,
} from "../Utils/Express";
import Response from "../Utils/Response";
import BaseAPI from "./BaseAPI";
import StatusPageSubscriber from "../../Models/DatabaseModels/StatusPageSubscriber";
export default class StatusPageSubscriberAPI extends BaseAPI<
StatusPageSubscriber,
StatusPageSubscriberServiceType
> {
public constructor() {
super(StatusPageSubscriber, StatusPageSubscriberService);
this.router.get(
`${new this.entityType().getCrudApiPath()?.toString()}/unsubscribe/:id`,
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
try {
await this.service.updateOneBy({
query: {
_id: req.params["id"] as string,
},
data: {
isUnsubscribed: true,
},
props: {
isRoot: true,
ignoreHooks: true,
},
});
return Response.sendHtmlResponse(
req,
res,
"<html><body><p> You have been unsubscribed.</p><body><html>",
);
} catch (err) {
next(err);
}
},
);
}
}