From fa4d080d0e5e8c837eba3446d0a73c1006a760e6 Mon Sep 17 00:00:00 2001 From: rob Date: Sat, 9 Jul 2022 06:13:44 -0400 Subject: [PATCH] push to Core and Sites --- app/services/core-node.js | 14 +++++++------- app/services/user-notification.js | 30 +++++++++++++++--------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/services/core-node.js b/app/services/core-node.js index 97e0531..d69e323 100644 --- a/app/services/core-node.js +++ b/app/services/core-node.js @@ -261,20 +261,20 @@ class CoreNodeService extends SiteService { return { connectedCount, pendingCount, potentialReach }; } - async sendKaleidoscopeEvent (author, event) { + async sendKaleidoscopeEvent (emitter, event) { const CORE_SCHEME = this.getCoreRequestScheme(); const { pkg } = this.dtp; const { site } = this.dtp.config; - const authorUrl = author.coreUserId ? `/user/core/${author._id}` : `/user/${author._id}`; + let emitterUrl = emitter.coreUserId ? `/user/core/${emitter._id}` : `/user/${emitter._id}`; event.source = Object.assign({ pkg: { name: pkg.name, version: pkg.version }, site, - author: { - userId: author._id.toString(), - displayName: author.displayName, - username: author.username, - href: `${CORE_SCHEME}://${site.domain}${authorUrl}`, + emitter: { + emitterId: emitter._id.toString(), + displayName: emitter.displayName, + username: emitter.username, + href: `${CORE_SCHEME}://${site.domain}${emitterUrl}`, }, }, event.source); diff --git a/app/services/user-notification.js b/app/services/user-notification.js index b75ecc6..ac00598 100644 --- a/app/services/user-notification.js +++ b/app/services/user-notification.js @@ -106,20 +106,20 @@ class UserNotificationService extends SiteService { } /* - * Validate source author + * Validate source emitter */ - if (!notificationDefinition.source.author) { - throw new SiteError(406, 'Missing source author information'); + if (!notificationDefinition.source.emitter) { + throw new SiteError(406, 'Missing source emitter information'); } - if (!notificationDefinition.source.author.userId) { - throw new SiteError(406, 'Missing source author userId'); + if (!notificationDefinition.source.emitter.emitterId) { + throw new SiteError(406, 'Missing source emitter ID'); } - if (!notificationDefinition.source.author.username) { - throw new SiteError(406, 'Missing source author username'); + if (!notificationDefinition.source.emitter.username) { + throw new SiteError(406, 'Missing source emitter username'); } - if (!notificationDefinition.source.author.href) { - throw new SiteError(406, 'Missing source author href'); + if (!notificationDefinition.source.emitter.href) { + throw new SiteError(406, 'Missing source emitter href'); } const notification = new UserNotification(); @@ -145,10 +145,10 @@ class UserNotificationService extends SiteService { scopes: notificationDefinition.source.site.coreAuth.scopes.map((scope) => scope.trim().toLowerCase()), }, }, - author: { - userId: mongoose.Types.ObjectId(notificationDefinition.source.author.userId), - username: striptags(notificationDefinition.source.author.username.trim()), - href: striptags(notificationDefinition.source.author.href.trim()), + emitter: { + emitterId: mongoose.Types.ObjectId(notificationDefinition.source.emitter.emitterId), + username: striptags(notificationDefinition.source.emitter.username.trim()), + href: striptags(notificationDefinition.source.emitter.href.trim()), }, }; @@ -159,8 +159,8 @@ class UserNotificationService extends SiteService { notification.source.site.description = striptags(notificationDefinition.source.site.description.trim()); } - if (notificationDefinition.source.author.displayName) { - notification.source.author.displayName = striptags(notificationDefinition.source.author.displayName); + if (notificationDefinition.source.emitter.displayName) { + notification.source.emitter.displayName = striptags(notificationDefinition.source.emitter.displayName); } notification.attachmentType = notificationDefinition.attachmentType;