Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const handleMessageReceived = protectedFunction((ddpMessage) => {
const message = buildMessage(EJSON.fromJSONValue(ddpMessage.fields.args[0]));
if (rid !== message.rid) {
return;
}
requestAnimationFrame(() => {
try {
database.write(() => {
database.create('messages', message, true);
// if it's a thread "header"
if (message.tlm) {
database.create('threads', message, true);
} else if (message.tmid) {
message.rid = message.tmid;
database.create('threadMessages', message, true);
}
});
function testFromJSONValue() {
var str: string = '{a:"a"}';
importedFromJSONValue(str);
}
export const merge = (subscription, room) => {
subscription = EJSON.fromJSONValue(subscription);
room = EJSON.fromJSONValue(room);
if (!subscription) {
return;
}
if (room) {
if (room.rid) {
subscription.rid = room.rid;
}
subscription.roomUpdatedAt = room._updatedAt;
subscription.lastMessage = normalizeMessage(room.lastMessage);
subscription.ro = room.ro;
subscription.description = room.description;
subscription.topic = room.topic;
subscription.announcement = room.announcement;
subscription.reactWhenReadOnly = room.reactWhenReadOnly;
subscription.archived = room.archived;
database.write(() => data.forEach((m) => {
try {
const message = buildMessage(EJSON.fromJSONValue(m));
message.rid = tmid;
database.create('threadMessages', message, true);
} catch (e) {
log('loadThreadMessages -> create messages', e);
}
}));
return resolve(data);
export const merge = (subscription, room) => {
subscription = EJSON.fromJSONValue(subscription);
room = EJSON.fromJSONValue(room);
if (!subscription) {
return;
}
if (room) {
if (room.rid) {
subscription.rid = room.rid;
}
subscription.roomUpdatedAt = room._updatedAt;
subscription.lastMessage = normalizeMessage(room.lastMessage);
subscription.ro = room.ro;
subscription.description = room.description;
subscription.topic = room.topic;
subscription.announcement = room.announcement;
subscription.reactWhenReadOnly = room.reactWhenReadOnly;
database.write(() => {
database.create('threads', buildMessage(EJSON.fromJSONValue(thread)), true);
});
} catch (e) {