diff --git a/app/models/user-notification.js b/app/models/user-notification.js index 73ed53c..efaf68d 100644 --- a/app/models/user-notification.js +++ b/app/models/user-notification.js @@ -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: { diff --git a/app/services/user-notification.js b/app/services/user-notification.js index ac00598..3bf0283 100644 --- a/app/services/user-notification.js +++ b/app/services/user-notification.js @@ -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());