made notification label optional

master
rob 2 years ago
parent fa4d080d0e
commit 2c1d5345a1

@ -12,7 +12,7 @@ const UserNotificationSchema = new Schema({
user: { type: Schema.ObjectId, required: true, index: 1, ref: 'User' },
status: { type: String, enum: ['new', 'seen'], default: 'new', required: true },
action: { type: String, required: true, lowercase: true },
label: { type: String, required: true },
label: { type: String },
content: { type: String },
href: { type: String },
source: {

@ -44,9 +44,6 @@ class UserNotificationService extends SiteService {
if (!notificationDefinition.action) {
throw new SiteError(406, 'Missing action');
}
if (!notificationDefinition.label) {
throw new SiteError(406, 'Missing label');
}
if (!notificationDefinition.content) {
throw new SiteError(406, 'Missing content');
}
@ -128,7 +125,9 @@ class UserNotificationService extends SiteService {
notification.status = 'new';
notification.action = striptags(notificationDefinition.action.trim().toLowerCase());
notification.label = striptags(notificationDefinition.label.trim());
if (notificationDefinition.label) {
notification.label = striptags(notificationDefinition.label.trim());
}
notification.content = striptags(notificationDefinition.content.trim());
notification.href = striptags(notificationDefinition.href.trim());

Loading…
Cancel
Save