reworked [un]muting user so it uses userId and userSecret

This commit is contained in:
Anton Georgiev 2014-11-18 19:35:51 +00:00
parent 45e1eb1ac3
commit 0f61fbed24
3 changed files with 38 additions and 20 deletions

View File

@ -198,7 +198,7 @@ Handlebars.registerHelper "visibility", (section) ->
setInSession("meetingName", null)
setInSession("userName", null)
@setInSession = (k, v) -> SessionAmplify.set k, v
@setInSession = (k, v) -> SessionAmplify.set k, v
@safeString = (str) ->
if typeof str is 'string'
@ -214,7 +214,7 @@ Handlebars.registerHelper "visibility", (section) ->
@toggleMic = (event) ->
u = Meteor.Users.findOne({_id:getInSession("DBID")})
if u?
Meteor.call('publishMuteRequest', getInSession("meetingId"),u._id, getInSession("userId"), u._id, not u.user.voiceUser.muted)
Meteor.call('muteUser', getInSession("meetingId"), u.userId, getInSession("userId"), getInSession("userSecret"), not u.user.voiceUser.muted)
@toggleNavbar = ->
setInSession "display_navbar", !getInSession "display_navbar"

View File

@ -29,27 +29,41 @@ Meteor.methods
Meteor.log.info "did not have enough information to send a mute_user_request"
# Verifies muter exists, provided proper credentials, and has permission to mute the user
publishMuteRequest: (meetingId, mutee_id, requesterUserId, requester_id, mutedBoolean) ->
Meteor.log.info "publishing a user mute #{mutedBoolean} request for #{mutee_id}"
mutee = Meteor.Users.findOne({'meetingId': meetingId, _id: mutee_id})
muter = Meteor.Users.findOne({'meetingId': meetingId, 'userId': requesterUserId, _id: requester_id})
if mutee? and muter?
# meetingId: the meetingId of the meeting the user[s] is in
# toMuteUserId: the userId of the user to be [un]muted
# requesterUserId: the userId of the requester
# requesterSecret: the userSecret of the requester
# mutedBoolean: true for muting, false for unmuting
muteUser: (meetingId, toMuteUserId, requesterUserId, requesterSecret, mutedBoolean) ->
action = ->
if mutedBoolean
if toMuteUserId is requesterUserId
return 'muteSelf'
else
return 'muteOther'
else
if toMuteUserId is requesterUserId
return 'unmuteSelf'
else
return 'unmuteOther'
if isAllowedTo(action(), meetingId, requesterUserId, requesterSecret)
message =
"payload":
"userid": mutee.userId
"meeting_id": meetingId
"mute": mutedBoolean
"requester_id": muter.userId
"header":
"timestamp": new Date().getTime()
"name": "mute_user_request"
"version": "0.0.1"
payload:
userid: toMuteUserId
meeting_id: meetingId
mute: mutedBoolean
requester_id: requesterUserId
header:
timestamp: new Date().getTime()
name: "mute_user_request"
version: "0.0.1"
Meteor.log.info "publishing a user mute #{mutedBoolean} request for #{toMuteUserId}"
publish Meteor.config.redis.channels.toBBBApps.voice, message
updateVoiceUser meetingId, {'user_id': mutee._id, talking:false, muted:mutedBoolean}
#
else
Meteor.log.info "did not have enough information to send a mute_user_request"
updateVoiceUser meetingId, {'web_userid': toMuteUserId, talking:false, muted:mutedBoolean}
return
# meetingId: the meetingId which both users are in
# toLowerUserId: the userid of the user to have their hand lowered

View File

@ -8,6 +8,10 @@ viewer =
raiseOwnHand : true
lowerOwnHand : true
# muting
muteSelf : true
unmuteSelf : true
@isAllowedTo = (action, meetingId, userId, secret) ->
user = Meteor.Users.findOne({meetingId:meetingId, userId: userId})