creating joinRoom method

pull/188/head
Gabriel Engel 11 years ago
parent 290d482780
commit a51138c1e6
  1. 11
      client/views/app/chatWindowDashboard.coffee
  2. 73
      client/views/app/chatWindowDashboard.html
  3. 6
      i18n/en.i18n.json
  4. 45
      server/methods/joinRoom.coffee

@ -17,9 +17,12 @@ Template.chatWindowDashboard.helpers
console.log 'chatWindowDashboard.helpers favorite' if window.rocketDebug
sub = ChatSubscription.findOne { rid: this._id }
return 'icon-star favorite-room' if sub?.f? and sub.f
return 'icon-star-empty'
subscribed: ->
console.log 'chatWindowDashboard.helpers subscribed' if window.rocketDebug
return ChatSubscription.findOne { rid: this._id }
messages: ->
console.log 'chatWindowDashboard.helpers messages' if window.rocketDebug
window.lastMessageWindow[this._id] = undefined
@ -298,6 +301,12 @@ Template.chatWindowDashboard.events
event.preventDefault()
Meteor.call 'toogleFavorite', this._id, !$('i', event.currentTarget).hasClass('favorite-room')
'click .join': (event) ->
console.log 'chatWindowDashboard click .join' if window.rocketDebug
event.stopPropagation()
event.preventDefault()
Meteor.call 'joinRoom', this._id
"click .burger": ->
console.log 'chatWindowDashboard click .burger' if window.rocketDebug
chatContainer = $("#rocket-chat")

@ -55,39 +55,46 @@
</div>
</div>
<footer class="footer">
<form class="message-form" method="post" action="/">
<div>
{{> messagePopupConfig getPupupConfig}}
<textarea dir="auto" name="msg" class="input-message"></textarea>
<i class="icon-paper-plane" title="{{_ "chatWindowDashboard.Send_Message"}}"></i>
</div>
<div class="users-typing">
{{#with usersTyping}}
<strong>{{users}}</strong>
{{#if multi}}
{{#if selfTyping}}
{{_ "chatWindowDashboard.are_also_typing"}}
{{else}}
{{_ "chatWindowDashboard.are_typing"}}
{{/if}}
{{else}}
{{#if selfTyping}}
{{_ "chatWindowDashboard.is_also_typing"}}
{{#if subscribed}}
<form class="message-form" method="post" action="/">
<div>
{{> messagePopupConfig getPupupConfig}}
<textarea dir="auto" name="msg" class="input-message"></textarea>
<i class="icon-paper-plane" title="{{_ "chatWindowDashboard.Send_Message"}}"></i>
</div>
<div class="users-typing">
{{#with usersTyping}}
<strong>{{users}}</strong>
{{#if multi}}
{{#if selfTyping}}
{{_ "chatWindowDashboard.are_also_typing"}}
{{else}}
{{_ "chatWindowDashboard.are_typing"}}
{{/if}}
{{else}}
{{_ "chatWindowDashboard.is_typing"}}
{{#if selfTyping}}
{{_ "chatWindowDashboard.is_also_typing"}}
{{else}}
{{_ "chatWindowDashboard.is_typing"}}
{{/if}}
{{/if}}
{{/if}}
{{/with}}
</div>
<div class="formatting-tips" aria-hidden="true" dir="auto">
<b>*bold*</b>
<i>_italics_</i> ~
<strike>strike</strike>~
<code class="inline">`inline code`</code>
<code class="inline">```⏎multi⏎line⏎```</code>
<q>&gt;quote</q>
{{/with}}
</div>
<div class="formatting-tips" aria-hidden="true" dir="auto">
<b>*bold*</b>
<i>_italics_</i> ~
<strike>strike</strike>~
<code class="inline">`inline code`</code>
<code class="inline">```⏎multi⏎line⏎```</code>
<q>&gt;quote</q>
</div>
</form>
{{else}}
<div>
{{_ "chatWindowDashboard.you_are_in_preview_mode_of"}} <strong>#{{roomName}}</strong>
<button class="button join"><span><i class="icon-login"></i> {{_ "chatWindowDashboard.join"}}</span></button>
</div>
</form>
{{/if}}
</footer>
</section>
<section class="flex-tab">
@ -128,9 +135,9 @@
{{#with userActiveByUsername .}}
<li class='user-image user-card-room status-{{status}}'>
<a data-username="{{username}}" tabindex="0" title="{{username}}">
{{> avatar username=username}}
<p>{{username}}</p>
</a>
{{> avatar username=username}}
<p>{{username}}</p>
</a>
</li>
{{/with}}
{{/each}}

@ -54,7 +54,9 @@
"Send_Message" : "Send Message",
"Showing_online_users" : "Showing <b>__total_online__</b> of __total__ users",
"Start_of_conversation" : "Start of conversation",
"View_All" : "View All"
"View_All" : "View All",
"you_are_in_preview_mode_of": "You are in preview mode of",
"join": "Join"
},
"footer" : {
"Follow_social_profiles" : "Follow our social profiles, fork us on github and share your thoughts about the rocket.chat app on our trello board.",
@ -164,4 +166,4 @@
"Use_uploaded_avatar" : "Use uploaded avatar",
"Select_file" : "Select file"
}
}
}

@ -0,0 +1,45 @@
Meteor.methods
joinRoom: (rid) ->
room = ChatRoom.findOne rid
if room.t isnt 'c'
throw new Meteor.Error 403, '[methods] joinRoom -> Not allowed'
# verify if user is already in room
# if room.usernames.indexOf(data.username) is -1
now = new Date()
update =
$push:
usernames:
$each: [data.username]
$sort: 1
newUser = Meteor.users.findOne username: data.username
ChatRoom.update data.rid, update
ChatSubscription.insert
rid: data.rid
ts: now
name: room.name
t: room.t
open: true
alert: true
unread: 1
u:
_id: newUser._id
username: data.username
ChatMessage.insert
rid: data.rid
ts: now
t: 'au'
msg: newUser.name
u:
_id: newUser._id
username: data.username
return true
Loading…
Cancel
Save