clean up some annots
This commit is contained in:
parent
bfa22c6dbd
commit
5bc37c132b
|
@ -1,6 +1,6 @@
|
||||||
open! Import
|
open! Import
|
||||||
open Result_syntax
|
open Result_syntax
|
||||||
type membership = Router.membership
|
open Router_types
|
||||||
|
|
||||||
include (val Logging.sublogs logger "Connection")
|
include (val Logging.sublogs logger "Connection")
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ type t = {
|
||||||
addr : sockaddr;
|
addr : sockaddr;
|
||||||
outbox : Outbox.t;
|
outbox : Outbox.t;
|
||||||
mutable activity : activity_state;
|
mutable activity : activity_state;
|
||||||
mutable user : User.t option;
|
mutable user : user option;
|
||||||
mutable pending_nick : name option;
|
mutable pending_nick : name option;
|
||||||
mutable pending_userinfo : userinfo option;
|
mutable pending_userinfo : userinfo option;
|
||||||
}
|
}
|
||||||
|
@ -94,23 +94,23 @@ let usersdontmatch_get = "502", ["Can't view mode for other users"]
|
||||||
|
|
||||||
(* permission checking *)
|
(* permission checking *)
|
||||||
|
|
||||||
let require_registered t : User.t result =
|
let require_registered t : user result =
|
||||||
match t.user with
|
match t.user with
|
||||||
| Some me -> Ok me
|
| Some me -> Ok me
|
||||||
| None -> Error notregistered
|
| None -> Error notregistered
|
||||||
|
|
||||||
let require_same_user user me =
|
let require_same_user user me =
|
||||||
if (user : User.t) == me then Ok () else Error usersdontmatch_get
|
if (user : user) == me then Ok () else Error usersdontmatch_get
|
||||||
|
|
||||||
let require_membership chan me =
|
let require_membership chan me =
|
||||||
match Router.membership chan me with
|
match Router.membership chan me with
|
||||||
| mem -> Ok mem
|
| mem -> Ok mem
|
||||||
| exception Not_found -> Error (notonchannel (Chan.name chan))
|
| exception Not_found -> Error (notonchannel (Chan.name chan))
|
||||||
|
|
||||||
let require_chan_op (m : membership) =
|
let require_chan_op mem =
|
||||||
match m.mem_priv with
|
match mem.mem_priv with
|
||||||
| Operator -> Ok ()
|
| Operator -> Ok ()
|
||||||
| _ -> Error (chanoprivsneeded (Chan.name m.mem_chan))
|
| _ -> Error (chanoprivsneeded (Chan.name mem.mem_chan))
|
||||||
|
|
||||||
|
|
||||||
(* modes *)
|
(* modes *)
|
||||||
|
@ -162,7 +162,7 @@ let set_chan_limit chan ~from chg =
|
||||||
Router.relay msg ~from [`to_chan chan; `to_self];
|
Router.relay msg ~from [`to_chan chan; `to_self];
|
||||||
Chan.set_limit chan limit
|
Chan.set_limit chan limit
|
||||||
|
|
||||||
let set_member_priv ~from (mem : membership) (priv : Router.priv) =
|
let set_member_priv ~from mem priv =
|
||||||
let user = mem.mem_user in
|
let user = mem.mem_user in
|
||||||
let chan = mem.mem_chan in
|
let chan = mem.mem_chan in
|
||||||
let modestr = match mem.mem_priv, priv with
|
let modestr = match mem.mem_priv, priv with
|
||||||
|
@ -339,9 +339,16 @@ let on_msg_away t status =
|
||||||
set_away t me status;
|
set_away t me status;
|
||||||
Ok ()
|
Ok ()
|
||||||
|
|
||||||
|
let membership_prefix = function
|
||||||
|
| Normal -> ""
|
||||||
|
| Voice -> "+"
|
||||||
|
| Operator -> "@"
|
||||||
|
|
||||||
|
let is_invisible user =
|
||||||
|
Mode.Set.mem `i (User.mode user)
|
||||||
|
|
||||||
let list_names t me chan =
|
let list_names t me chan =
|
||||||
let is_secret = Mode.Set.mem `s (Chan.mode chan) in
|
let is_secret = Mode.Set.mem `s (Chan.mode chan) in
|
||||||
let is_invisible user = Mode.Set.mem `i (User.mode user) in
|
|
||||||
|
|
||||||
let members =
|
let members =
|
||||||
match Router.membership chan me with
|
match Router.membership chan me with
|
||||||
|
@ -351,15 +358,14 @@ let list_names t me chan =
|
||||||
[]
|
[]
|
||||||
else
|
else
|
||||||
Chan.membership_when
|
Chan.membership_when
|
||||||
(fun (m : membership) ->
|
(fun mem -> not (is_invisible mem.mem_user))
|
||||||
not (is_invisible m.mem_user))
|
|
||||||
chan
|
chan
|
||||||
in
|
in
|
||||||
|
|
||||||
let nicks =
|
let nicks =
|
||||||
List.map
|
List.map
|
||||||
(fun (m : membership) ->
|
(fun mem ->
|
||||||
Router.membership_prefix m.mem_priv ^ User.nick m.mem_user)
|
membership_prefix mem.mem_priv ^ User.nick mem.mem_user)
|
||||||
members
|
members
|
||||||
in
|
in
|
||||||
|
|
||||||
|
@ -461,7 +467,7 @@ let on_msg_join t name =
|
||||||
Ok ()
|
Ok ()
|
||||||
end
|
end
|
||||||
|
|
||||||
let leave t (mem : membership) ~from ~why =
|
let leave t mem ~from ~why =
|
||||||
let user = mem.mem_user in
|
let user = mem.mem_user in
|
||||||
let chan = mem.mem_chan in
|
let chan = mem.mem_chan in
|
||||||
begin match why with
|
begin match why with
|
||||||
|
@ -547,7 +553,7 @@ let user_who_flags user =
|
||||||
end ^
|
end ^
|
||||||
(* Optionally, the highest channel membership prefix that the client has in <channel>,
|
(* Optionally, the highest channel membership prefix that the client has in <channel>,
|
||||||
if the client has one. *)
|
if the client has one. *)
|
||||||
Router.membership_prefix (User.highest_membership_priv user)
|
membership_prefix (User.highest_membership_priv user)
|
||||||
|
|
||||||
let list_who t chan users =
|
let list_who t chan users =
|
||||||
let chan_str = match chan with
|
let chan_str = match chan with
|
||||||
|
@ -597,8 +603,8 @@ let list_whois t user =
|
||||||
|
|
||||||
(* TODO: concat channel names until message becomes too long *)
|
(* TODO: concat channel names until message becomes too long *)
|
||||||
List.iter
|
List.iter
|
||||||
(fun (m : membership) ->
|
(fun mem ->
|
||||||
let chan_str = Router.membership_prefix m.mem_priv ^ Chan.name m.mem_chan in
|
let chan_str = membership_prefix mem.mem_priv ^ Chan.name mem.mem_chan in
|
||||||
reply t ("319", [nick; chan_str]))
|
reply t ("319", [nick; chan_str]))
|
||||||
(User.membership user);
|
(User.membership user);
|
||||||
|
|
||||||
|
|
|
@ -55,11 +55,6 @@ let membership chan user =
|
||||||
Dllist.find_node_l (fun mem -> mem.mem_chan == chan)
|
Dllist.find_node_l (fun mem -> mem.mem_chan == chan)
|
||||||
user.membership |> Dllist.get
|
user.membership |> Dllist.get
|
||||||
|
|
||||||
let membership_prefix = function
|
|
||||||
| Normal -> ""
|
|
||||||
| Voice -> "+"
|
|
||||||
| Operator -> "@"
|
|
||||||
|
|
||||||
let part mem =
|
let part mem =
|
||||||
try
|
try
|
||||||
Dllist.remove (Option.get mem.mem_in_user);
|
Dllist.remove (Option.get mem.mem_in_user);
|
||||||
|
|
Loading…
Reference in New Issue