UNPKG

@sync-in/server

Version:

The secure, open-source platform for file storage, sharing, collaboration, and sync

133 lines (132 loc) 6.49 kB
/* * Copyright (C) 2012-2025 Johan Legrand <johan.legrand@sync-in.com> * This file is part of Sync-in | The open source file sync and share solution * See the LICENSE file for licensing details */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get }); } _export(exports, { get commentMail () { return commentMail; }, get linkMail () { return linkMail; }, get shareMail () { return shareMail; }, get spaceMail () { return spaceMail; }, get spaceRootMail () { return spaceRootMail; }, get syncMail () { return syncMail; } }); const _appconstants = require("../../../app.constants"); const _constants = require("../../../common/constants"); const _shared = require("../../../common/shared"); const _files = require("../../files/utils/files"); const _i18n = require("../i18n"); const _templates = require("./templates"); const _urls = require("./urls"); function commentMail(language, notification, options) { const tr = (0, _i18n.translateObject)(language, { title: 'Comment', defaultFooter: _templates.defaultFooter, footer: 'You receive this notification if you are the owner of the file or if you have also commented on this file', urlText: 'Access it from', event: notification.event }); const content = `${(0, _templates.mailAuthor)(options.author)}${(0, _templates.mailEventOnElement)(tr.event, notification.element)}${(0, _templates.mailItalicContent)(options.content)}`; const footer = `<br>${tr.urlText}&nbsp;<a href="${(0, _urls.urlFromSpaceFile)(options.currentUrl, notification)}">${_appconstants.SERVER_NAME}</a><br>${tr.footer}<br>${tr.defaultFooter}`; return [ `${tr.title}: ${(0, _shared.capitalizeString)(notification.element)}`, (0, _templates.mailTemplate)(content, footer) ]; } function spaceMail(language, notification, options) { const tr = (0, _i18n.translateObject)(language, { title: 'Space', defaultFooter: _templates.defaultFooter, urlText: options.action === _constants.ACTION.ADD ? 'Access it from' : 'Access your spaces from', event: notification.event }); const spaceUrl = (0, _urls.urlFromSpace)(options.currentUrl, options.action === _constants.ACTION.ADD ? notification.element : undefined); const content = `${(0, _templates.mailEventOnElement)(tr.event, notification.element)}`; const footer = `<br>${tr.urlText}&nbsp;<a href="${spaceUrl}">${_appconstants.SERVER_NAME}</a><br>${tr.defaultFooter}`; return [ `${tr.title}: ${(0, _shared.capitalizeString)(notification.element)}`, (0, _templates.mailTemplate)(content, footer) ]; } function spaceRootMail(language, notification, options) { const tr = (0, _i18n.translateObject)(language, { title: 'Space', defaultFooter: _templates.defaultFooter, urlText: options.action === _constants.ACTION.ADD ? 'Access it from' : 'Access this space from', event: notification.event, originEvent: options.action === _constants.ACTION.ADD ? 'to the space' : 'from the space' }); const spaceName = (0, _files.fileName)(notification.url); const spaceRootUrl = options.action === _constants.ACTION.ADD ? (0, _urls.urlFromSpaceFile)(options.currentUrl, notification) : (0, _urls.urlFromSpace)(options.currentUrl, spaceName); const content = `${(0, _templates.mailAuthor)(options.author)}${(0, _templates.mailEventOnElement)(tr.event, notification.element)}&nbsp;${tr.originEvent}&nbsp;<b>${spaceName}</b>`; const footer = `<br>${tr.urlText}&nbsp;<a href="${spaceRootUrl}">${_appconstants.SERVER_NAME}</a><br>${tr.defaultFooter}`; return [ `${tr.title}: ${(0, _shared.capitalizeString)(spaceName)}`, (0, _templates.mailTemplate)(content, footer) ]; } function shareMail(language, notification, options) { const tr = (0, _i18n.translateObject)(language, { title: 'Share', defaultFooter: _templates.defaultFooter, urlText: options.action === _constants.ACTION.ADD ? 'Access it from' : 'Access your shares from', event: notification.event }); const content = `${options.author ? (0, _templates.mailAuthor)(options.author) : ''}${(0, _templates.mailEventOnElement)(tr.event, notification.element)}`; const footer = `<br>${tr.urlText}&nbsp;<a href="${(0, _urls.urlFromSpaceFile)(options.currentUrl, notification)}">${_appconstants.SERVER_NAME}</a><br>${tr.defaultFooter}`; return [ `${tr.title}: ${(0, _shared.capitalizeString)(notification.element)}`, (0, _templates.mailTemplate)(content, footer) ]; } function linkMail(language, notification, options) { const tr = (0, _i18n.translateObject)(language, { title: options.action === _constants.ACTION.ADD ? 'Share' : 'Space', defaultFooter: _templates.defaultFooter, urlText: 'Access it from', event: notification.event }); const content = `${options.author ? (0, _templates.mailAuthor)(options.author) : ''}${(0, _templates.mailEventOnElement)(tr.event, notification.element)}`; const footer = `<br>${tr.urlText}&nbsp;<a href="${(0, _urls.urlFromLink)(options.currentUrl, options.linkUUID)}">${_appconstants.SERVER_NAME}</a><br>${tr.defaultFooter}`; return [ `${tr.title}: ${(0, _shared.capitalizeString)(notification.element)}`, (0, _templates.mailTemplate)(content, footer) ]; } function syncMail(language, notification, options) { const tr = (0, _i18n.translateObject)(language, { title: 'Sync', defaultFooter: _templates.defaultFooter, urlText: options.action === _constants.ACTION.ADD ? 'Access it from' : 'Access your syncs from', event: notification.event }); const syncUrl = (0, _urls.urlFromSync)(options.currentUrl); const content = `${(0, _templates.mailEventOnElement)(tr.event, notification.element)}`; const footer = `<br>${tr.urlText}&nbsp;<a href="${syncUrl}">${_appconstants.SERVER_NAME}</a><br>${tr.defaultFooter}`; return [ `${tr.title}: ${(0, _shared.capitalizeString)(notification.element)}`, (0, _templates.mailTemplate)(content, footer) ]; } //# sourceMappingURL=models.js.map