open-health/imports/api/updateInfo.js

39 lines
1 KiB
JavaScript
Raw Permalink Normal View History

2025-12-06 15:44:43 -06:00
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/check';
export const UpdateInfo = new Mongo.Collection('updateInfo');
UpdateInfo.allow({
insert: function(userId, doc){
// if use id exists, allow insert
return !!userId;
},
});
Meteor.methods({
2026-02-03 16:03:34 -06:00
async 'add.updateInfo' (updateObject) {
2025-12-06 15:44:43 -06:00
check(updateObject, Object);
2026-02-03 16:03:34 -06:00
return await UpdateInfo.insertAsync({
2025-12-06 15:44:43 -06:00
title: updateObject.title,
description: updateObject.description,
dateRelease: updateObject.date,
releaseLink: updateObject.link
});
},
2026-02-03 16:03:34 -06:00
async 'markUpdate.read' (updateId) {
2025-12-06 15:44:43 -06:00
check(updateId, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to mark updates as read. Make sure you are logged in with valid user credentials.');
}
2026-02-03 16:03:34 -06:00
return await UpdateInfo.updateAsync({ _id: updateId }, {
2025-12-06 15:44:43 -06:00
$set: {
viewed: true
}
});
}
});