UNPKG

@brontosaurus/db

Version:
65 lines (64 loc) 3.1 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getApplicationOtherInformationByKey = exports.getApplicationOtherInformationByApplication = void 0; const array_1 = require("@sudoo/bark/array"); const application_1 = require("./application"); const preference_1 = require("./preference"); const getApplicationOtherInformationByApplication = (application) => __awaiter(void 0, void 0, void 0, function* () { const response = { avatar: application.avatar, backgroundImage: application.backgroundImage, favicon: application.favicon, helpLink: application.helpLink, privacyPolicy: application.privacyPolicy, }; if (!response.avatar) { const globalAvatar = yield preference_1.getSinglePreference('globalAvatar'); if (globalAvatar) { response.avatar = globalAvatar; } } if (!response.backgroundImage) { const globalBackgroundImages = yield preference_1.getSinglePreference('globalBackgroundImages'); if (globalBackgroundImages) { response.backgroundImage = array_1._Array.sample(globalBackgroundImages); } } if (!response.favicon) { const globalFavicon = yield preference_1.getSinglePreference('globalFavicon'); if (globalFavicon) { response.favicon = globalFavicon; } } if (!response.helpLink) { const globalHelpLink = yield preference_1.getSinglePreference('globalHelpLink'); if (globalHelpLink) { response.helpLink = globalHelpLink; } } if (!response.privacyPolicy) { const globalPrivacyPolicy = yield preference_1.getSinglePreference('globalPrivacyPolicy'); if (globalPrivacyPolicy) { response.privacyPolicy = globalPrivacyPolicy; } } return response; }); exports.getApplicationOtherInformationByApplication = getApplicationOtherInformationByApplication; const getApplicationOtherInformationByKey = (key) => __awaiter(void 0, void 0, void 0, function* () { const application = yield application_1.getApplicationByKeyLean(key); if (!application) { return null; } return yield exports.getApplicationOtherInformationByApplication(application); }); exports.getApplicationOtherInformationByKey = getApplicationOtherInformationByKey;