Mobile notifications

This commit is contained in:
Vicente J. Ruiz Jurado 2018-08-02 12:42:19 +02:00
parent 47e9c18607
commit bf926514c9
13 changed files with 762 additions and 506 deletions

View file

@ -2,6 +2,7 @@
/* eslint-disable import/no-absolute-path */
import { Mongo } from 'meteor/mongo';
import { Meteor } from 'meteor/meteor';
import SimpleSchema from 'simpl-schema';
import { defaultCreatedAt, defaultUpdateAt } from '/imports/api/Utility/Utils.js';
import LocationSchema from '/imports/api/Utility/LocationSchema.js';
@ -22,11 +23,12 @@ Notifications.deny({
Notifications.schema = new SimpleSchema({
userId: String,
subsId: { type: Meteor.Collection.ObjectID, optional: true, blackbox: true },
content: String,
geo: LocationSchema,
type: String,
webNotified: { type: Boolean, optional: true },
webNotifiedAt: { type: Date, optional: true },
notified: { type: Boolean, optional: true },
notifiedAt: { type: Date, optional: true },
emailNotified: { type: Boolean, optional: true },
emailNotifiedAt: { type: Date, optional: true },
when: Date,

View file

@ -8,7 +8,7 @@ Meteor.methods({
check(notifId, Meteor.Collection.ObjectID);
try {
Notifications.update(notifId, { $set: { webNotified: true, webNotifiedAt: new Date() } });
Notifications.update(notifId, { $set: { notified: true, notifiedAt: new Date() } });
return notifId;
} catch (exception) {
throw new Meteor.Error('500', exception);

View file

@ -4,7 +4,7 @@ import { Meteor } from 'meteor/meteor';
import Notifications from '../Notifications';
Meteor.publish('mynotifications', function notifications() {
const notif = Notifications.find({ userId: this.userId, type: 'web', webNotified: null });
const notif = Notifications.find({ userId: this.userId, type: 'web', notified: null });
// console.log(`Notifications for user ${this.userId}: ${notif.count()}`);
return notif;
});