|
|
@ -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;
|
|
|
|