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.23.2.15 -r1.23.2.16 --- openacs-4/packages/chat/tcl/chat-ajax-procs.tcl 8 Mar 2023 12:57:05 -0000 1.23.2.15 +++ openacs-4/packages/chat/tcl/chat-ajax-procs.tcl 13 Mar 2023 14:04:37 -0000 1.23.2.16 @@ -115,9 +115,24 @@ set uid [expr {$uid ne "" ? $uid : ${:user_id}}] - # Check write permissions + # + # Check write permissions for the chat user + # + if {[string is integer -strict $uid]} { + # + # The uid is an integer, that we expect to correspond to a + # party_id. + # + set party_id $uid + } else { + # + # The uid is another kind of anonymous identifier + # (e.g. the IP address). We map these to the public. + # + set party_id [acs_magic_object the_public] + } permission::require_permission \ - -party_id $uid \ + -party_id $party_id \ -object_id ${:chat_id} \ -privilege "chat_write" @@ -129,10 +144,16 @@ # code around expects the return value of the original method set retval [next] - # This way messages can be persisted immediately every time a - # message is sent + # + # Persist the chat message. We take note of the creation user, + # which may be The Public for anonymous participants and the + # IP address. + # if {[:current_message_valid]} { - $r post_message -msg $msg -creation_user $uid + $r post_message \ + -msg $msg \ + -creation_user $party_id \ + -creation_ip [ad_conn peeraddr] } return $retval