fix placement of welcome message issue
This commit is contained in:
parent
7f07e686dd
commit
c4d7d70dce
@ -68,8 +68,10 @@ Meteor.methods
|
||||
from_username: messageObject.from_username
|
||||
from_lang: messageObject.from_lang
|
||||
}, (err, numChanged) ->
|
||||
if err?
|
||||
Meteor.log.error "_error #{err} when adding chat to collection"
|
||||
if numChanged.insertedId?
|
||||
Meteor.log.error "added chat id=[#{numChanged.insertedId}]
|
||||
Meteor.log.info "_added chat id=[#{numChanged.insertedId}]
|
||||
#{messageObject.from_username} to #{'PUBLIC' if messageObject.to_username?}:#{messageObject.message}")
|
||||
|
||||
# called on server start and meeting end
|
||||
|
@ -260,26 +260,32 @@ Meteor.methods
|
||||
locked=#{user.locked}, username=#{user.name}"
|
||||
)
|
||||
|
||||
# only add the welcome message if it's not there already
|
||||
unless Meteor.Chat.findOne({"message.chat_type":'SYSTEM_MESSAGE', "message.to_userid": userId})?
|
||||
welcomeMessage = Meteor.config.defaultWelcomeMessage
|
||||
.replace /%%CONFNAME%%/, Meteor.Meetings.findOne({meetingId: meetingId})?.meetingName
|
||||
welcomeMessage = welcomeMessage + Meteor.config.defaultWelcomeMessageFooter
|
||||
|
||||
# store the welcome message in chat for easy display on the client side
|
||||
Meteor.Chat.insert({
|
||||
meetingId: meetingId
|
||||
message:
|
||||
chat_type: "SYSTEM_MESSAGE"
|
||||
message: welcomeMessage
|
||||
from_color: '0x3399FF'
|
||||
to_userid: userId
|
||||
from_userid: "SYSTEM_MESSAGE"
|
||||
from_username: ""
|
||||
from_time: user.timeOfJoining?.toString()
|
||||
}, (err) ->
|
||||
Meteor.log.info "_added a system message in chat for user #{userId}"
|
||||
)
|
||||
welcomeMessage = Meteor.config.defaultWelcomeMessage
|
||||
.replace /%%CONFNAME%%/, Meteor.Meetings.findOne({meetingId: meetingId})?.meetingName
|
||||
welcomeMessage = welcomeMessage + Meteor.config.defaultWelcomeMessageFooter
|
||||
# add the welcome message if it's not there already OR update time_of_joining
|
||||
Meteor.Chat.upsert({
|
||||
meetingId: meetingId
|
||||
userId: userId
|
||||
'message.chat_type': 'SYSTEM_MESSAGE'
|
||||
'message.to_userid': userId
|
||||
}, {
|
||||
meetingId: meetingId
|
||||
userId: userId
|
||||
message:
|
||||
chat_type: 'SYSTEM_MESSAGE'
|
||||
message: welcomeMessage
|
||||
from_color: '0x3399FF'
|
||||
to_userid: userId
|
||||
from_userid: 'SYSTEM_MESSAGE'
|
||||
from_username: ''
|
||||
from_time: user.timeOfJoining?.toString()
|
||||
}, (err, numChanged) ->
|
||||
if err?
|
||||
Meteor.log.error "_error #{err} when trying to insert welcome message for #{userId}"
|
||||
else
|
||||
Meteor.log.info "_added/updated a system message in chat for user #{userId}"
|
||||
)
|
||||
|
||||
else
|
||||
# Meteor.log.info "NOTE: got user_joined_message #{user.name} #{user.userid}"
|
||||
|
@ -150,6 +150,7 @@ class Meteor.RedisPubSub
|
||||
if dbUser?.clientType is "HTML5" # typically html5 users will be in the db [as a dummy user] before the joining message
|
||||
status = dbUser?.validated
|
||||
Meteor.log.info "in user_joined_message the validStatus of the user was #{status}"
|
||||
userObj.timeOfJoining = message.header.current_time
|
||||
userJoined meetingId, userObj
|
||||
return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user