mirror of
https://github.com/wahyd4/sohub.git
synced 2026-08-23 20:06:02 +10:00
40 lines
908 B
JavaScript
40 lines
908 B
JavaScript
module.exports = {
|
|
|
|
attributes: {
|
|
|
|
content: 'STRING',
|
|
createTime: 'FLOAT',
|
|
toUser: 'STRING',
|
|
fromUser: 'STRING',
|
|
messageType: 'STRING',
|
|
messageId: 'FLOAT'
|
|
},
|
|
|
|
/**
|
|
* 判断消息是否是通知消息
|
|
* @param string
|
|
* @returns {boolean}
|
|
*/
|
|
isValidNoticeMessage: function (string) {
|
|
return new RegExp('^[+]{1}[^+]*$').test(string);
|
|
},
|
|
/**
|
|
* 将普通文本消息改为通知类消息
|
|
* @param messageId
|
|
*/
|
|
changeToNotice: function (messageId) {
|
|
Message.update({
|
|
_id: messageId
|
|
}, {
|
|
messageType: 'notice'
|
|
}, function (err, message) {
|
|
if (err) {
|
|
return console.log(err);
|
|
} else {
|
|
console.log("Message updated:", message);
|
|
return message;
|
|
}
|
|
});
|
|
}
|
|
|
|
}; |