push to Core and Sites

master
rob 2 years ago
parent 336dcd3918
commit fa4d080d0e

@ -261,20 +261,20 @@ class CoreNodeService extends SiteService {
return { connectedCount, pendingCount, potentialReach }; return { connectedCount, pendingCount, potentialReach };
} }
async sendKaleidoscopeEvent (author, event) { async sendKaleidoscopeEvent (emitter, event) {
const CORE_SCHEME = this.getCoreRequestScheme(); const CORE_SCHEME = this.getCoreRequestScheme();
const { pkg } = this.dtp; const { pkg } = this.dtp;
const { site } = this.dtp.config; 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({ event.source = Object.assign({
pkg: { name: pkg.name, version: pkg.version }, pkg: { name: pkg.name, version: pkg.version },
site, site,
author: { emitter: {
userId: author._id.toString(), emitterId: emitter._id.toString(),
displayName: author.displayName, displayName: emitter.displayName,
username: author.username, username: emitter.username,
href: `${CORE_SCHEME}://${site.domain}${authorUrl}`, href: `${CORE_SCHEME}://${site.domain}${emitterUrl}`,
}, },
}, event.source); }, event.source);

@ -106,20 +106,20 @@ class UserNotificationService extends SiteService {
} }
/* /*
* Validate source author * Validate source emitter
*/ */
if (!notificationDefinition.source.author) { if (!notificationDefinition.source.emitter) {
throw new SiteError(406, 'Missing source author information'); throw new SiteError(406, 'Missing source emitter information');
} }
if (!notificationDefinition.source.author.userId) { if (!notificationDefinition.source.emitter.emitterId) {
throw new SiteError(406, 'Missing source author userId'); throw new SiteError(406, 'Missing source emitter ID');
} }
if (!notificationDefinition.source.author.username) { if (!notificationDefinition.source.emitter.username) {
throw new SiteError(406, 'Missing source author username'); throw new SiteError(406, 'Missing source emitter username');
} }
if (!notificationDefinition.source.author.href) { if (!notificationDefinition.source.emitter.href) {
throw new SiteError(406, 'Missing source author href'); throw new SiteError(406, 'Missing source emitter href');
} }
const notification = new UserNotification(); const notification = new UserNotification();
@ -145,10 +145,10 @@ class UserNotificationService extends SiteService {
scopes: notificationDefinition.source.site.coreAuth.scopes.map((scope) => scope.trim().toLowerCase()), scopes: notificationDefinition.source.site.coreAuth.scopes.map((scope) => scope.trim().toLowerCase()),
}, },
}, },
author: { emitter: {
userId: mongoose.Types.ObjectId(notificationDefinition.source.author.userId), emitterId: mongoose.Types.ObjectId(notificationDefinition.source.emitter.emitterId),
username: striptags(notificationDefinition.source.author.username.trim()), username: striptags(notificationDefinition.source.emitter.username.trim()),
href: striptags(notificationDefinition.source.author.href.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()); notification.source.site.description = striptags(notificationDefinition.source.site.description.trim());
} }
if (notificationDefinition.source.author.displayName) { if (notificationDefinition.source.emitter.displayName) {
notification.source.author.displayName = striptags(notificationDefinition.source.author.displayName); notification.source.emitter.displayName = striptags(notificationDefinition.source.emitter.displayName);
} }
notification.attachmentType = notificationDefinition.attachmentType; notification.attachmentType = notificationDefinition.attachmentType;

Loading…
Cancel
Save