[Git][noosfero/noosfero][cherry-pick-63f4b816] Merge branch 'chat-refresh' into 'master'
Rodrigo Souto
gitlab at mg.gitlab.com
Mon Oct 24 15:21:27 BRST 2016
Rodrigo Souto pushed to branch cherry-pick-63f4b816 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
- - - - -
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/commit/2d0c2710699d489c90c36cfbceabb3444c9ff483
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20161024/863b9479/attachment-0001.html>
More information about the Noosfero-dev
mailing list