Use flat object instead of long properties
This commit is contained in:
parent
f0e26c1bbb
commit
05e1951ac1
@ -1,3 +1,4 @@
|
|||||||
|
import flat from 'flat';
|
||||||
import Chat from '/imports/api/2.0/chat';
|
import Chat from '/imports/api/2.0/chat';
|
||||||
import Logger from '/imports/startup/server/logger';
|
import Logger from '/imports/startup/server/logger';
|
||||||
import { check } from 'meteor/check';
|
import { check } from 'meteor/check';
|
||||||
@ -17,7 +18,8 @@ const parseMessage = (message) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function addChat(meetingId, message) {
|
export default function addChat(meetingId, message) {
|
||||||
const parsedMessage = parseMessage(message.message);
|
const parsedMessage = message;
|
||||||
|
parsedMessage.message = parseMessage(message.message);
|
||||||
|
|
||||||
const fromUserId = message.fromUserId;
|
const fromUserId = message.fromUserId;
|
||||||
const toUserId = message.toUserId;
|
const toUserId = message.toUserId;
|
||||||
@ -27,24 +29,15 @@ export default function addChat(meetingId, message) {
|
|||||||
|
|
||||||
const selector = {
|
const selector = {
|
||||||
meetingId,
|
meetingId,
|
||||||
'message.fromTime': message.fromTime,
|
'message.fromTime': parsedMessage.fromTime,
|
||||||
'message.fromUserId': message.fromUserId,
|
'message.fromUserId': parsedMessage.fromUserId,
|
||||||
'message.toUserId': message.toUserId,
|
'message.toUserId': parsedMessage.toUserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const modifier = {
|
const modifier = {
|
||||||
$set: {
|
$set: {
|
||||||
meetingId,
|
meetingId,
|
||||||
message: {
|
message: flat(parsedMessage),
|
||||||
message: parsedMessage,
|
|
||||||
toUsername: message.toUsername,
|
|
||||||
fromTimezoneOffset: message.fromTimezoneOffset,
|
|
||||||
fromColor: message.fromColor,
|
|
||||||
toUserId: message.toUserId,
|
|
||||||
fromUserId: message.fromUserId,
|
|
||||||
fromTime: message.fromTime,
|
|
||||||
fromUsername: message.fromUsername,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user