[Git][noosfero/noosfero][stable-1.6] 2 commits: Merge branch 'chat-refresh' into 'master'
Rodrigo Souto
gitlab at mg.gitlab.com
Mon Oct 24 18:43:20 BRST 2016
Rodrigo Souto pushed to branch stable-1.6 at Noosfero / noosfero
Commits:
2d0c2710 by Rodrigo Souto at 2016-10-24T17:21:18+00:00
Merge branch 'chat-refresh' into 'master'
chat: verify refreshed sessions
See merge request !1030
- - - - -
5f8cdba9 by Rodrigo Souto at 2016-10-24T20:42:10+00:00
Merge branch 'cherry-pick-63f4b816' into 'stable-1.6'
Merge branch 'chat-refresh' into 'master'
chat: verify refreshed sessions
See merge request !1030
See merge request !1033
- - - - -
2 changed files:
- app/controllers/public/chat_controller.rb
- app/models/user.rb
Changes:
=====================================
app/controllers/public/chat_controller.rb
=====================================
--- a/app/controllers/public/chat_controller.rb
+++ b/app/controllers/public/chat_controller.rb
@@ -121,9 +121,10 @@ class ChatController < PublicController
end
def availabilities
+ current_user.update_column(:chat_status_at, DateTime.now)
availabilities = user.friends.map do |friend|
status = friend.user.chat_status
- status = 'offline' if status.blank?
+ status = 'offline' if status.blank? || !friend.user.chat_alive?
{:jid => friend.jid, :status => status}
end
render :text => availabilities.to_json
=====================================
app/models/user.rb
=====================================
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -411,6 +411,10 @@ class User < ApplicationRecord
15 # in minutes
end
+ # Chat was not refreshed in the last 20 seconds. The window was closed.
+ def chat_alive?
+ (DateTime.now - chat_status_at.to_datetime) * 1.day <= 20
+ end
def not_require_password!
@is_password_required = false
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/b76cf339b48888283a1b5cbec6b06da023a524dd...5f8cdba9fd83a634ce9d591fd37c57aaff87d23f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20161024/1326bdfd/attachment-0001.html>
More information about the Noosfero-dev
mailing list