mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
ubsubscribed
This commit is contained in:
parent
c49235bafb
commit
f06e5f95f0
@ -1 +1 @@
|
||||
ONEUPTIME_SECRET=fd57b59aa8f3f516d2f6cb06
|
||||
ONEUPTIME_SECRET=ae60cf8f0cec2df8d05aaf0b
|
54
CommonServer/API/StatusPageSubscriberAPI.ts
Normal file
54
CommonServer/API/StatusPageSubscriberAPI.ts
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
import StatusPageSubscriber from 'Model/Models/StatusPageSubscriber';
|
||||
import StatusPageSubscriberService, {
|
||||
Service as StatusPageSubscriberServiceType,
|
||||
} from '../Services/StatusPageSubscriberService';
|
||||
import {
|
||||
ExpressRequest,
|
||||
ExpressResponse,
|
||||
NextFunction,
|
||||
} from '../Utils/Express';
|
||||
import BaseAPI from './BaseAPI';
|
||||
import Response from '../Utils/Response';
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -95,7 +95,7 @@ export class Service extends DatabaseService<Model> {
|
||||
statusPageName: statusPageName,
|
||||
statusPageUrl: statusPageURL,
|
||||
isPublicStatusPage: onCreate.carryForward.isPublicStatusPage,
|
||||
unsubscribeUrl: new URL(HttpProtocol, Domain).addRoute("/status-page-subscriber/unsubscribe/" + createdItem._id.toString()).toString()
|
||||
unsubscribeUrl: new URL(HttpProtocol, Domain).addRoute("/api/status-page-subscriber/unsubscribe/" + createdItem._id.toString()).toString()
|
||||
},
|
||||
subject: 'You have been subscribed to ' + statusPageName,
|
||||
}).catch((err: Error) => {
|
||||
|
@ -263,4 +263,26 @@ export default class Response {
|
||||
oneUptimeResponse.status(200).send(text);
|
||||
this.logResponse(req, res, { text: text as string });
|
||||
}
|
||||
|
||||
|
||||
public static sendHtmlResponse(
|
||||
req: ExpressRequest,
|
||||
res: ExpressResponse,
|
||||
html: string
|
||||
): void {
|
||||
const oneUptimeRequest: OneUptimeRequest = req as OneUptimeRequest;
|
||||
const oneUptimeResponse: OneUptimeResponse = res as OneUptimeResponse;
|
||||
|
||||
oneUptimeResponse.set(
|
||||
'ExpressRequest-Id',
|
||||
oneUptimeRequest.id.toString()
|
||||
);
|
||||
|
||||
oneUptimeResponse.set('Pod-Id', process.env['POD_NAME']);
|
||||
|
||||
oneUptimeResponse.logBody = { html: html as string };
|
||||
oneUptimeResponse.writeHead(200, { 'Content-Type':'text/html'});
|
||||
oneUptimeResponse.end(html);
|
||||
this.logResponse(req, res, { html: html as string });
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import NotNull from 'Common/Types/Database/NotNull';
|
||||
import StatusPagePreviewLink from './StatusPagePreviewLink';
|
||||
import { JSONObject } from 'Common/Types/JSON';
|
||||
import Pill from 'CommonUI/src/Components/Pill/Pill';
|
||||
import { Green, Red } from 'Common/Types/BrandColors';
|
||||
// import NotNull from 'Common/Types/Database/NotNull';
|
||||
|
||||
const StatusPageDelete: FunctionComponent<PageComponentProps> = (
|
||||
@ -151,8 +152,6 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return <></>;
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -30,10 +30,6 @@ import StatusPagePrivateUserService, {
|
||||
Service as StatusPagePrivateUserServiceType,
|
||||
} from 'CommonServer/Services/StatusPagePrivateUserService';
|
||||
|
||||
import StatusPageSubscriber from 'Model/Models/StatusPageSubscriber';
|
||||
import StatusPageSubscriberService, {
|
||||
Service as StatusPageSubscriberServiceType,
|
||||
} from 'CommonServer/Services/StatusPageSubscriberService';
|
||||
|
||||
import StatusPageFooterLink from 'Model/Models/StatusPageFooterLink';
|
||||
import StatusPageFooterLinkService, {
|
||||
@ -189,6 +185,8 @@ import StatusPageDomainService, {
|
||||
|
||||
import StatusPageAPI from 'CommonServer/API/StatusPageAPI';
|
||||
|
||||
import StatusPageSubscriberAPI from 'CommonServer/API/StatusPageSubscriberAPI';
|
||||
|
||||
const app: ExpressApplication = Express.getExpressApp();
|
||||
|
||||
const APP_NAME: string = 'api';
|
||||
@ -289,12 +287,6 @@ app.use(
|
||||
).getRouter()
|
||||
);
|
||||
|
||||
app.use(
|
||||
new BaseAPI<StatusPageSubscriber, StatusPageSubscriberServiceType>(
|
||||
StatusPageSubscriber,
|
||||
StatusPageSubscriberService
|
||||
).getRouter()
|
||||
);
|
||||
|
||||
app.use(
|
||||
new BaseAPI<StatusPagePrivateUser, StatusPagePrivateUserServiceType>(
|
||||
@ -389,6 +381,7 @@ app.use(
|
||||
);
|
||||
|
||||
app.use(new StatusPageAPI().getRouter());
|
||||
app.use(new StatusPageSubscriberAPI().getRouter());
|
||||
app.use(new BillingPaymentMethodAPI().getRouter());
|
||||
app.use(new BillingInvoiceAPI().getRouter());
|
||||
|
||||
|
@ -114,7 +114,10 @@ server {
|
||||
}
|
||||
|
||||
server {
|
||||
|
||||
listen 443 ssl; # Port HTTPS
|
||||
listen 80;
|
||||
|
||||
server_name localhost;
|
||||
{{ if ne .Env.DOMAIN "localhost" }}
|
||||
server_name {{ .Env.DOMAIN }};
|
||||
|
Loading…
Reference in New Issue
Block a user