[Git][noosfero/noosfero][master] 2 commits: chat: verify refreshed sessions
Rodrigo Souto
gitlab at mg.gitlab.com
Mon Oct 24 15:20:29 BRST 2016
Rodrigo Souto pushed to branch master at Noosfero / noosfero
Commits:
94d4457b by Rodrigo Souto at 2016-09-19T13:28:34-03:00
chat: verify refreshed sessions
- - - - -
63f4b816 by Rodrigo Souto at 2016-10-24T17:20:15+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/compare/f0c37fa89e65ede1eb3f545395d75b34c4a09849...63f4b816be4c6e228570014ef0817a17ce8d3b99
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20161024/7356d09d/attachment-0001.html>
More information about the Noosfero-dev
mailing list