clean up some annots

This commit is contained in:
tali 2024-01-31 10:42:12 -05:00
parent bfa22c6dbd
commit 5bc37c132b
2 changed files with 23 additions and 22 deletions

View File

@ -1,6 +1,6 @@
open! Import
open Result_syntax
type membership = Router.membership
open Router_types
include (val Logging.sublogs logger "Connection")
@ -12,7 +12,7 @@ type t = {
addr : sockaddr;
outbox : Outbox.t;
mutable activity : activity_state;
mutable user : User.t option;
mutable user : user option;
mutable pending_nick : name option;
mutable pending_userinfo : userinfo option;
}
@ -94,23 +94,23 @@ let usersdontmatch_get = "502", ["Can't view mode for other users"]
(* permission checking *)
let require_registered t : User.t result =
let require_registered t : user result =
match t.user with
| Some me -> Ok me
| None -> Error notregistered
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 =
match Router.membership chan me with
| mem -> Ok mem
| exception Not_found -> Error (notonchannel (Chan.name chan))
let require_chan_op (m : membership) =
match m.mem_priv with
let require_chan_op mem =
match mem.mem_priv with
| Operator -> Ok ()
| _ -> Error (chanoprivsneeded (Chan.name m.mem_chan))
| _ -> Error (chanoprivsneeded (Chan.name mem.mem_chan))
(* modes *)
@ -162,7 +162,7 @@ let set_chan_limit chan ~from chg =
Router.relay msg ~from [`to_chan chan; `to_self];
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 chan = mem.mem_chan in
let modestr = match mem.mem_priv, priv with
@ -339,9 +339,16 @@ let on_msg_away t status =
set_away t me status;
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 is_secret = Mode.Set.mem `s (Chan.mode chan) in
let is_invisible user = Mode.Set.mem `i (User.mode user) in
let members =
match Router.membership chan me with
@ -351,15 +358,14 @@ let list_names t me chan =
[]
else
Chan.membership_when
(fun (m : membership) ->
not (is_invisible m.mem_user))
(fun mem -> not (is_invisible mem.mem_user))
chan
in
let nicks =
List.map
(fun (m : membership) ->
Router.membership_prefix m.mem_priv ^ User.nick m.mem_user)
(fun mem ->
membership_prefix mem.mem_priv ^ User.nick mem.mem_user)
members
in
@ -461,7 +467,7 @@ let on_msg_join t name =
Ok ()
end
let leave t (mem : membership) ~from ~why =
let leave t mem ~from ~why =
let user = mem.mem_user in
let chan = mem.mem_chan in
begin match why with
@ -547,7 +553,7 @@ let user_who_flags user =
end ^
(* Optionally, the highest channel membership prefix that the client has in <channel>,
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 chan_str = match chan with
@ -597,8 +603,8 @@ let list_whois t user =
(* TODO: concat channel names until message becomes too long *)
List.iter
(fun (m : membership) ->
let chan_str = Router.membership_prefix m.mem_priv ^ Chan.name m.mem_chan in
(fun mem ->
let chan_str = membership_prefix mem.mem_priv ^ Chan.name mem.mem_chan in
reply t ("319", [nick; chan_str]))
(User.membership user);

View File

@ -55,11 +55,6 @@ let membership chan user =
Dllist.find_node_l (fun mem -> mem.mem_chan == chan)
user.membership |> Dllist.get
let membership_prefix = function
| Normal -> ""
| Voice -> "+"
| Operator -> "@"
let part mem =
try
Dllist.remove (Option.get mem.mem_in_user);