Index: openacs-4/packages/chat/tcl/chat-ajax-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/chat/tcl/chat-ajax-procs.tcl,v diff -u -r1.19 -r1.20 --- openacs-4/packages/chat/tcl/chat-ajax-procs.tcl 20 Sep 2018 13:28:30 -0000 1.19 +++ openacs-4/packages/chat/tcl/chat-ajax-procs.tcl 28 Sep 2018 11:44:23 -0000 1.20 @@ -8,78 +8,30 @@ } namespace eval ::chat { - ::xo::ChatClass Chat -superclass ::xo::Chat + ::xo::ChatClass Chat -superclass ::xowiki::Chat + Chat instproc initialize_nsvs {} { + next + + # read the last_activity information at server start into a nsv array + ::xo::dc foreach get_rooms { + select room_id, to_char(max(creation_date),'HH24:MI:SS YYYY-MM-DD') as last_activity + from chat_msgs group by room_id + } { + ::xo::clusterwide nsv_set [self]-$room_id-seen last [clock scan $last_activity] + } + } + Chat instproc init {} { - :instvar chat_id - if {[chat_room_exists_p $chat_id]} { - chat_room_get -room_id $chat_id -array c + if {[chat_room_exists_p ${:chat_id}]} { + chat_room_get -room_id ${:chat_id} -array c set :login_messages_p $c(login_messages_p) set :logout_messages_p $c(logout_messages_p) set :timewindow $c(messages_time_window) } next } - Chat proc login {-chat_id -package_id} { - auth::require_login - if {![info exists package_id]} { - set package_id [ad_conn package_id] - } - if {![info exists chat_id]} { - set chat_id $package_id - } - - set path [lindex [site_node::get_url_from_object_id -object_id $package_id] 0] - set base_url ${path}ajax/chat - template::head::add_javascript -src ${base_url}.js - set base_url [export_vars -base ${base_url} {{id $chat_id} {s "[ad_conn session_id].[clock seconds]"}}] - - set login_url [ns_quotehtml "${base_url}&m=login"] - set send_url "${base_url}&m=add_msg&msg=" - set users_url [ns_quotehtml "${base_url}&m=get_users"] - set html_url [ns_quotehtml [ad_conn url]?[ad_conn query]] - regsub {client=ajax} $html_url {client=html} html_url - - return [subst { - -
- - - - <p>#chat.Your_browser_doesnt_support_#</p> - <p><a href='$html_url'>#chat.Go_to_html_version#</a></p> - -
- #chat.message# - -
-
- - - }] - } - # if chat doesn't exist anymore, send a message that will inform # the user of being looking at an invalid chat Chat instproc check_valid_room {} {