From 289a95523d16785f081c5d8ff1e36b03dd8253b3 Mon Sep 17 00:00:00 2001 From: titanism <101466223+titanism@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:31:14 -0500 Subject: [PATCH] feat: added support for calendar-user-address-set --- common/tags.js | 20 +++++++++++++++++++- package.json | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/common/tags.js b/common/tags.js index b986b68..432a8ba 100644 --- a/common/tags.js +++ b/common/tags.js @@ -1,3 +1,4 @@ +const { isEmail } = require('validator'); const { buildTag, href, response, status } = require('./x-build'); const winston = require('./winston'); @@ -255,7 +256,24 @@ module.exports = function (options) { } }, 'calendar-user-address-set': { - doc: 'https://tools.ietf.org/html/rfc6638#section-2.4.1' + doc: 'https://tools.ietf.org/html/rfc6638#section-2.4.1', + async resp({ ctx }) { + if (isEmail(ctx.state.user.principalName)) + return { + [buildTag(cal, 'calendar-user-address-set')]: href( + `mailto:${ctx.state.user.principalName}` + ) + }; + if (isEmail(ctx.state.user.email)) + return { + [buildTag(cal, 'calendar-user-address-set')]: href( + `mailto:${ctx.state.user.email}` + ) + }; + return { + [buildTag(cal, 'calendar-user-address-set')]: '' + }; + } }, 'default-alarm-vevent-date': { doc: 'https://tools.ietf.org/id/draft-daboo-valarm-extensions-01.html#rfc.section.9', diff --git a/package.json b/package.json index a328fc3..8bda3f3 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "moment": "^2.30.1", "path-to-regexp": "^6.2.1", "raw-body": "^2.5.2", + "validator": "^13.12.0", "winston": "^3.11.0", "xmlbuilder2": "^3.1.1", "xpath": "0.0.34"