import DatabaseService from "./DatabaseService";
import Model from "../../Models/DatabaseModels/StatusPageAnnouncement";
import StatusPageSubscriberNotificationStatus from "../../Types/StatusPage/StatusPageSubscriberNotificationStatus";
export class Service extends DatabaseService {
    constructor() {
        super(Model);
    }
    async onBeforeCreate(createBy) {
        // Set notification status based on shouldStatusPageSubscribersBeNotified
        if (createBy.data.shouldStatusPageSubscribersBeNotified === false) {
            createBy.data.subscriberNotificationStatus =
                StatusPageSubscriberNotificationStatus.Skipped;
            createBy.data.subscriberNotificationStatusMessage =
                "Notifications skipped as subscribers are not to be notified for this announcement.";
        }
        else if (createBy.data.shouldStatusPageSubscribersBeNotified === true) {
            createBy.data.subscriberNotificationStatus =
                StatusPageSubscriberNotificationStatus.Pending;
        }
        return {
            createBy,
            carryForward: null,
        };
    }
    async onBeforeUpdate(updateBy) {
        // Set notification status based on shouldStatusPageSubscribersBeNotified if it's being updated
        if (updateBy.data.shouldStatusPageSubscribersBeNotified !== undefined) {
            if (updateBy.data.shouldStatusPageSubscribersBeNotified === false) {
                updateBy.data.subscriberNotificationStatus =
                    StatusPageSubscriberNotificationStatus.Skipped;
                updateBy.data.subscriberNotificationStatusMessage =
                    "Notifications skipped as subscribers are not to be notified for this announcement.";
            }
            else if (updateBy.data.shouldStatusPageSubscribersBeNotified === true) {
                updateBy.data.subscriberNotificationStatus =
                    StatusPageSubscriberNotificationStatus.Pending;
            }
        }
        return {
            updateBy,
            carryForward: null,
        };
    }
}
export default new Service();
//# sourceMappingURL=StatusPageAnnouncementService.js.map