mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 07:10:53 +00:00
Refactor unsubscribe URL generation in StatusPageSubscriberService
This commit is contained in:
parent
32e72a8817
commit
59ab24ba36
@ -189,12 +189,7 @@ export class Service extends DatabaseService<Model> {
|
||||
.isPublicStatusPage
|
||||
? 'true'
|
||||
: 'false',
|
||||
unsubscribeUrl: new URL(httpProtocol, host)
|
||||
.addRoute(
|
||||
'/api/status-page-subscriber/unsubscribe/' +
|
||||
createdItem._id.toString()
|
||||
)
|
||||
.toString(),
|
||||
unsubscribeUrl: this.getUnsubscribeLink(URL.fromString(statusPageURL), createdItem.id!).toString()
|
||||
},
|
||||
subject: 'You have been subscribed to ' + statusPageName,
|
||||
},
|
||||
@ -229,5 +224,10 @@ export class Service extends DatabaseService<Model> {
|
||||
props: props,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public getUnsubscribeLink(statusPageUrl: URL, statusPageSubscriberId: ObjectID): URL {
|
||||
return URL.fromString(statusPageUrl.toString()).addRoute('/update-subscription/'+statusPageSubscriberId.toString());
|
||||
}
|
||||
}
|
||||
export default new Service();
|
||||
|
@ -132,12 +132,7 @@ RunCron(
|
||||
continue;
|
||||
}
|
||||
|
||||
const unsubscribeUrl: string = new URL(httpProtocol, host)
|
||||
.addRoute(
|
||||
'/api/status-page-subscriber/unsubscribe/' +
|
||||
subscriber._id.toString()
|
||||
)
|
||||
.toString();
|
||||
const unsubscribeUrl: string = StatusPageSubscriberService.getUnsubscribeLink(URL.fromString(statusPageURL), subscriber.id!).toString();;
|
||||
|
||||
if (subscriber.subscriberPhone) {
|
||||
const sms: SMS = {
|
||||
|
@ -190,12 +190,7 @@ RunCron(
|
||||
continue;
|
||||
}
|
||||
|
||||
const unsubscribeUrl: string = new URL(httpProtocol, host)
|
||||
.addRoute(
|
||||
'/api/status-page-subscriber/unsubscribe/' +
|
||||
subscriber._id.toString()
|
||||
)
|
||||
.toString();
|
||||
const unsubscribeUrl: string = StatusPageSubscriberService.getUnsubscribeLink(URL.fromString(statusPageURL), subscriber.id!).toString();
|
||||
|
||||
if (subscriber.subscriberEmail) {
|
||||
// send email here.
|
||||
|
@ -212,12 +212,7 @@ RunCron(
|
||||
continue;
|
||||
}
|
||||
|
||||
const unsubscribeUrl: string = new URL(httpProtocol, host)
|
||||
.addRoute(
|
||||
'/api/status-page-subscriber/unsubscribe/' +
|
||||
subscriber._id.toString()
|
||||
)
|
||||
.toString();
|
||||
const unsubscribeUrl: string = StatusPageSubscriberService.getUnsubscribeLink(URL.fromString(statusPageURL), subscriber.id!).toString();;
|
||||
|
||||
if (subscriber.subscriberPhone) {
|
||||
const sms: SMS = {
|
||||
|
@ -220,12 +220,7 @@ RunCron(
|
||||
continue;
|
||||
}
|
||||
|
||||
const unsubscribeUrl: string = new URL(httpProtocol, host)
|
||||
.addRoute(
|
||||
'/api/status-page-subscriber/unsubscribe/' +
|
||||
subscriber._id.toString()
|
||||
)
|
||||
.toString();
|
||||
const unsubscribeUrl: string = StatusPageSubscriberService.getUnsubscribeLink(URL.fromString(statusPageURL), subscriber.id!).toString();;
|
||||
|
||||
if (subscriber.subscriberPhone) {
|
||||
const sms: SMS = {
|
||||
|
@ -194,12 +194,7 @@ RunCron(
|
||||
continue;
|
||||
}
|
||||
|
||||
const unsubscribeUrl: string = new URL(httpProtocol, host)
|
||||
.addRoute(
|
||||
'/api/status-page-subscriber/unsubscribe/' +
|
||||
subscriber._id.toString()
|
||||
)
|
||||
.toString();
|
||||
const unsubscribeUrl: string = StatusPageSubscriberService.getUnsubscribeLink(URL.fromString(statusPageURL), subscriber.id!).toString();;
|
||||
|
||||
if (subscriber.subscriberPhone) {
|
||||
const sms: SMS = {
|
||||
|
@ -206,12 +206,7 @@ RunCron(
|
||||
continue;
|
||||
}
|
||||
|
||||
const unsubscribeUrl: string = new URL(httpProtocol, host)
|
||||
.addRoute(
|
||||
'/api/status-page-subscriber/unsubscribe/' +
|
||||
subscriber._id.toString()
|
||||
)
|
||||
.toString();
|
||||
const unsubscribeUrl: string = StatusPageSubscriberService.getUnsubscribeLink(URL.fromString(statusPageURL), subscriber.id!).toString();;
|
||||
|
||||
if (subscriber.subscriberPhone) {
|
||||
const sms: SMS = {
|
||||
|
@ -218,12 +218,7 @@ RunCron(
|
||||
continue;
|
||||
}
|
||||
|
||||
const unsubscribeUrl: string = new URL(httpProtocol, host)
|
||||
.addRoute(
|
||||
'/api/status-page-subscriber/unsubscribe/' +
|
||||
subscriber._id.toString()
|
||||
)
|
||||
.toString();
|
||||
const unsubscribeUrl: string = StatusPageSubscriberService.getUnsubscribeLink(URL.fromString(statusPageURL), subscriber.id!).toString();;
|
||||
|
||||
if (subscriber.subscriberPhone) {
|
||||
const sms: SMS = {
|
||||
|
Loading…
Reference in New Issue
Block a user