locking for public chat

This commit is contained in:
Anton Georgiev 2015-03-30 22:48:25 +00:00
parent b47e8f3330
commit 7b3d6497c2
5 changed files with 37 additions and 17 deletions

View File

@ -113,6 +113,12 @@
padding: 5px;
}
.disabledChat {
background-color: grey;
width: 100% !important;
}
.dropdown {
float: left;
@media @desktop-portrait, @mobile-portrait, @mobile-portrait-with-keyboard {

View File

@ -65,6 +65,14 @@ Handlebars.registerHelper "grabChatTabs", ->
setInSession 'chatTabs', initTabs
getInSession('chatTabs')[0..3]
Handlebars.registerHelper "publicChatDisabled", ->
userIsLocked = Meteor.Users.findOne({userId:getInSession 'userId'})?.user.locked
console.log "userIsLocked=" + userIsLocked
publicChatIsDisabled = Meteor.Meetings.findOne({})?.roomLockSettings.disablePubChat
console.log "publicChatIsDisabled=" + publicChatIsDisabled
return userIsLocked and publicChatIsDisabled
@sendMessage = ->
message = linkify $('#newMessageInput').val() # get the message from the input box
unless (message?.length > 0 and (/\S/.test(message))) # check the message has content and it is not whitespace

View File

@ -27,12 +27,16 @@
</template>
<template name="chatInput">
<div id="chatInput" class="chat-input-wrapper">
<textarea id="newMessageInput" placeholder="Write a message..." rel="tooltip" data-placement="top" title="Write a new message"></textarea>
<button type="submit" id="sendMessageButton" class="btn" rel="tooltip" data-placement="top" title="Click to send your message">
Send
</button>
</div>
<div id="chatInput" class="chat-input-wrapper">
{{#if publicChatDisabled}}
<textarea id="newMessageInput" class="disabledChat" placeholder="Public chat is temporarily locked (disabled)" rel="tooltip" data-placement="top" title="Public chat is temporarily locked"></textarea>
{{else}}
<textarea id="newMessageInput" placeholder="Write a message..." rel="tooltip" data-placement="top" title="Write a new message"></textarea>
<button type="submit" id="sendMessageButton" class="btn" rel="tooltip" data-placement="top" title="Click to send your message">
Send
</button>
{{/if}}
</div>
</template>
<template name="chatOptions">

View File

@ -1,8 +1,4 @@
Meteor.methods
#
# I dont know if this is okay to be server side. We need to call it from the router, but I don't know if any harm can be caused
# by the client calling this
#
# Construct and send a message to bbb-web to validate the user
validateAuthToken: (meetingId, userId, authToken) ->
@ -70,6 +66,11 @@ class Meteor.RedisPubSub
# "get_users_reply"
"get_chat_history_reply"
"get_all_meetings_reply"
"presentation_shared_message"
"presentation_conversion_done_message"
"presentation_conversion_progress_message"
"presentation_page_generated_message"
"presentation_page_changed_message"
]
if message?.header? and message?.payload?
@ -287,8 +288,6 @@ class Meteor.RedisPubSub
return
if message.header.name is "new_permission_settings"
console.log "\n22222"
# meetingId = message.payload.meeting_id
# substitute with the new lock settings
Meteor.Meetings.update({meetingId: meetingId}, {$set: {
@ -302,7 +301,6 @@ class Meteor.RedisPubSub
return
if message.header.name is "user_locked_message" or message.header.name is "user_unlocked_message"
console.log "\n33333333"
userId = message.payload.userid
isLocked = message.payload.locked
setUserLockedStatus(meetingId, userId, isLocked)

View File

@ -22,7 +22,7 @@ moderator =
chatPrivate: true #should make this dynamically modifiable later on
viewer =
viewer = (meetingId, userId) ->
# raising/lowering hand
raiseOwnHand : true
lowerOwnHand : true
@ -38,12 +38,16 @@ viewer =
subscribeChat: true
#chat
chatPublic: true #should make this dynamically modifiable later on
chatPrivate: true #should make this dynamically modifiable later on
chatPublic: !(Meteor.Meetings.findOne({meetingId:meetingId})?.roomLockSettings.disablePubChat) or
!(Meteor.Users.findOne({meetingId:meetingId, userId:userId})?.user.locked)
chatPrivate: !(Meteor.Meetings.findOne({meetingId:meetingId})?.roomLockSettings.disablePrivChat) or
!(Meteor.Users.findOne({meetingId:meetingId, userId:userId})?.user.locked)
@isAllowedTo = (action, meetingId, userId, authToken) ->
# Disclaimer:the current version of the HTML5 client represents only VIEWER users
Meteor.log.error "#{action} : " + viewer(meetingId, userId)[action]
validated = Meteor.Users.findOne({meetingId:meetingId, userId: userId})?.validated
Meteor.log.info "in isAllowedTo: action-#{action}, userId=#{userId}, authToken=#{authToken} validated:#{validated}"
@ -52,7 +56,7 @@ viewer =
if user? and authToken is user.authToken # check if the user is who he claims to be
if user.validated and user.clientType is "HTML5"
if user.user?.role is 'VIEWER' or user.user?.role is 'MODERATOR' or user.user?.role is undefined
return viewer[action] or false
return viewer(meetingId)[action] or false
else
Meteor.log.warn "UNSUCCESSFULL ATTEMPT FROM userid=#{userId} to perform:#{action}"
return false