Browse Source

made notification label optional

pull/1/head
Rob Colbert 3 years ago
parent
commit
2c1d5345a1
  1. 2
      app/models/user-notification.js
  2. 7
      app/services/user-notification.js

2
app/models/user-notification.js

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

7
app/services/user-notification.js

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

Loading…
Cancel
Save