/* eslint-disable no-console */ import { globalEnv } from "../../../../common/globalEnv.js"; import BasePushService, { IPushToken, IPushPayload } from "../BasePushService.js"; import SecureFetchBuilder from "../../../../common/fetch/SecureFetchBuilder.js"; import { RegisterSingleton } from "@entity-access/entity-access/dist/di/di.js"; const client = SecureFetchBuilder .url(`https://${globalEnv.otpIn.host}/`) .logWhenFailed(console.error) .header("authorization", `basic ${Buffer.from(`${globalEnv.otpIn.key}:${globalEnv.otpIn.secret}`).toString("base64")}`); @RegisterSingleton export default class ForwardPushService extends BasePushService { protected async initConfig() { return; } protected pushMessage({ deviceToken, deviceTokenType }: IPushToken, payload: IPushPayload) { return client.post(`/social-mail/push/send/${deviceTokenType}`).jsonBody({ token: {deviceToken, deviceTokenType}, payload }).asJson(); } }