fix send_to_chan: non mebers cant send to moderated channels
This commit is contained in:
parent
81918b9813
commit
a34651b283
|
@ -280,22 +280,22 @@ let on_msg_mode t name args =
|
|||
Ok ()
|
||||
|
||||
|
||||
(* messages and channels *)
|
||||
(* messages *)
|
||||
|
||||
let get_priv_opt chan user =
|
||||
try
|
||||
let mem = Router.membership chan user in
|
||||
Some mem.mem_priv
|
||||
with Not_found ->
|
||||
None
|
||||
|
||||
let send_to_chan ~from chan =
|
||||
let cannot_send =
|
||||
try
|
||||
let mem = Router.membership chan from in
|
||||
(* check if moderated (+m) *)
|
||||
if Mode.Set.mem `m (Chan.mode chan) then
|
||||
mem.mem_priv < Voice
|
||||
else
|
||||
false
|
||||
with Not_found ->
|
||||
(* check if no external messages (+n) *)
|
||||
Mode.Set.mem `n (Chan.mode chan)
|
||||
let priv_required =
|
||||
if Mode.Set.mem `m (Chan.mode chan) then Some Voice
|
||||
else if Mode.Set.mem `n (Chan.mode chan) then Some Normal
|
||||
else None
|
||||
in
|
||||
if cannot_send then
|
||||
if get_priv_opt chan from < priv_required then
|
||||
Error (cannotsendtochan (Chan.name chan))
|
||||
else
|
||||
Ok (Chan.name chan, [`to_chan chan])
|
||||
|
@ -336,6 +336,9 @@ let on_msg_away t status =
|
|||
set_away t me status;
|
||||
Ok ()
|
||||
|
||||
|
||||
(* channels *)
|
||||
|
||||
let membership_prefix = function
|
||||
| Normal -> ""
|
||||
| Voice -> "+"
|
||||
|
|
Loading…
Reference in New Issue