Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
$scope.sendText = () => {
const {draft} = $scope;
if (!draft) {
return;
}
const message = new TextMessage(draft);
// 匹配出所有的 @
const results = draft.match(/(^|\s)@(\S*)/g);
if (results) {
const mentionMatchResults = new Set(results.map(match => match.trim().slice(1)));
console.log(mentionMatchResults);
// 找出 @all
if (mentionMatchResults.has('all')) {
message.mentionAll();
mentionMatchResults.delete('all');
}
message.setMentionList(Array.from(mentionMatchResults));
}
$scope.draft = '';
$scope.smileysShow = false;
return $scope.send(message);
function sendMessage(content, peerId, convId) {
console.log('sending message [' + content + '] to peer [' + peerId + ']');
var message = new TextMessage(content);
var conversation = AV.Object.createWithoutData('_Conversation', convId);
return conversation.send('MathBot', message, { toClients: [peerId] }, { useMasterKey: true }).then(function() {
console.log('sended: ' + JSON.stringify(message));
}, function(error) {
console.error('send message error: ' + error.message);
});
}
SharedService.client.getConversation(convIdStr, true).then(conv => {
let txtMessage = new TextMessage(sendEventData.text);
console.log(JSON.stringify(this.items));
console.log('send(sendEventData)');
return conv.send(txtMessage);
}).then(message => {
this.updateLastMessage(message);
AV.Cloud.define('chime', function() {
if (!CHIME_CONV_ID) return console.warn('CHIME_CONV_ID not set, skip chiming');
console.log('chime');
var hours = Math.round((Date.now() / 3600000 + 8) % 24);
var message = new TextMessage('北京时间 ' + hours + ' 点整');
var conversation = AV.Object.createWithoutData('_Conversation', CHIME_CONV_ID);
return conversation.broadcast('LeanObservatory', message, { validTill: Date.now() }, { useMasterKey: true }).then(function() {
console.log('chimed');
}, function(error) {
console.error('broadcast message error: ' + error.message);
});
});