Comparison

teal-src/plugins/muc/muc.lib.d.tl @ 12891:93ce4244d433

MUC: Start on a Teal description of MUC rooms Started as part of a documentation project for the MUC API
author Kim Alvefur <zash@zash.se>
date Mon, 20 Feb 2023 15:08:06 +0100
child 12892:d788714fcf21
comparison
equal deleted inserted replaced
12890:05b3b3dc7326 12891:93ce4244d433
1 local Stanza = require "util.stanza".stanza_t
2
3 local record Room
4 jid : string
5
6 enum Affiliation
7 "outcast"
8 "none"
9 "member"
10 "admin"
11 "owner"
12 end
13
14 enum Role
15 "none"
16 "visitor"
17 "participant"
18 "moderator"
19 end
20
21 record Occupant
22 bare_jid : string
23 nick : string
24 sessions : { string : Stanza }
25 role : Role
26 jid : string
27 end
28
29 -- Private properties
30 _jid_nick : { string : string }
31 _occupants : { string : Occupant }
32 _data : { string : any }
33 _affiliations : { string : Affiliation }
34 _affiliation_data : { string : { string : any } }
35
36 -- Occupant methods
37 get_occupant_jid : function (Room, real_jid : string) : string
38 new_occupant : function (Room, bare_real_jid : string, nick : string) : Occupant
39 get_occupant_by_nick : function (Room, nick : string) : Occupant
40 type OccupantIterator = function ({string:Occupant}, occupant_jid : string) : string, Occupant
41 each_occupant : function (Room, read_only : boolean) : OccupantIterator, {string:Occupant}, nil
42 has_occupant : function (Room) : boolean
43 get_occupant_by_real_jid : function (Room, real_jid : string) : Occupant
44 save_occupant :function (Room, Occupant) : Occupant
45
46 -- Affiliation methods
47 type AffiliationIterator = function (any, jid : string) : string, Affiliation
48 get_affiliation : function (Room, jid : string) : Affiliation
49 each_affiliation : function (Room, Affiliation) : AffiliationIterator, nil, nil
50 set_affiliation : function (Room, jid : string, Affiliation, reason : string, data : { string : any }) : boolean, string, string, string -- ok + error tripplet
51 get_affiliation_data : function (Room, jid : string, key : string) : any
52 set_affiliation_data : function (Room, jid : string, key : string, value : any) : boolean
53 get_registered_nick : function (Room, jid : string) : string
54 get_registered_jid : function (Room, nick : string) : string
55
56 -- Role methods
57 get_default_role : function (Room, Affiliation) : Role, integer
58 get_role : function (Room, nick : string) : Role
59 may_set_role : function (Room, actor : string, Occupant, Role) : boolean
60 set_role : function (Room, actor : string, occupant_jid : string, Role, reason : string) : boolean, string, string, string
61
62 -- Routing input, generally handled by mod_muc and hooked up to Prosody routing events
63 handle_first_presence : function (Room, table, Stanza) : boolean
64 handle_normal_presence : function (Room, table, Stanza) : boolean
65 handle_presence_to_room : function (Room, table, Stanza) : boolean
66 handle_presence_to_occupant : function (Room, table, Stanza) : boolean
67 handle_message_to_room : function (Room, table, Stanza) : boolean
68 handle_message_to_occupant : function (Room, table, Stanza) : boolean
69 handle_groupchat_to_room : function (Room, table, Stanza) : boolean
70 handle_iq_to_occupant : function (Room, table, Stanza) : boolean
71 handle_disco_info_get_query : function (Room, table, Stanza) : boolean
72 handle_disco_items_get_query : function (Room, table, Stanza) : boolean
73 handle_admin_query_set_command : function (Room, table, Stanza) : boolean
74 handle_admin_query_get_command : function (Room, table, Stanza) : boolean
75 handle_owner_query_get_to_room : function (Room, table, Stanza) : boolean
76 handle_owner_query_set_to_room : function (Room, table, Stanza) : boolean
77 handle_mediated_invite : function (Room, table, Stanza) : boolean
78 handle_mediated_decline : function (Room, table, Stanza) : boolean
79 handle_role_request : function (Room, table, Stanza) : boolean
80 handle_register_iq : function (Room, table, Stanza) : boolean
81 handle_kickable : function (Room, table, Stanza) : boolean
82
83 -- Routing output
84 broadcast : function (Room, Stanza, function (nick : string, Occupant) : boolean)
85 broadcast_message : function (Room, Stanza) : boolean
86 route_stanza : function (Room, Stanza)
87 route_to_occupant : function (Room, Occupant, Stanza)
88
89 -- Sending things to someone joining
90 publicise_occupant_status : function (Room, Occupant, x : Stanza, nick : string, actor : string, reason : string, prev_role : Role, force_unavailable : boolean, recipient : Occupant)
91 send_occupant_list : function (Room, to : string, filter : function (occupant_jid : string, Occupant) : boolean)
92 send_history : function (Room, Stanza)
93 send_subject : function (Room, to : string, time : number)
94
95 respond_to_probe : function (Room, table, Stanza, Occupant)
96
97 -- Constructors for various answer stanzas
98 get_disco_info : function (Room, Stanza) : Stanza
99 get_disco_items : function (Room, Stanza) : Stanza
100
101 build_item_list : function (Room, Occupant, Stanza, is_anonymous : boolean, nick : string, actor_nick : string, actor_jid : string, reason : string) : Stanza
102 build_unavailable_presence : function (Room, from_muc_jid : string, to_jid : string) : Stanza
103
104 -- Form handling
105 send_form : function (Room, table, Stanza)
106 get_form_layout : function (Room, actor : string) : table
107 process_form : function (Room, table, Stanza) : boolean
108
109 -- Properties and configuration
110 get_name : function (Room) : string
111 set_name : function (Room, string) : boolean
112 get_description : function (Room) : string
113 set_description : function (Room, string) : boolean
114 get_language : function (Room) : string
115 set_language : function (Room, string) : boolean
116 get_hidden : function (Room) : boolean
117 set_hidden : function (Room, boolean)
118 get_public : function (Room) : boolean
119 set_public : function (Room, boolean)
120 get_password : function (Room) : string
121 set_password : function (Room, string) : boolean
122 get_members_only : function (Room) : boolean
123 set_members_only : function (Room, boolean) : boolean
124 get_allow_member_invites : function (Room) : boolean
125 set_allow_member_invites : function (Room, boolean) : boolean
126 get_moderated : function (Room) : boolean
127 set_moderated : function (Room, boolean) : boolean
128 get_persistent : function (Room) : boolean
129 set_persistent : function (Room, boolean) : boolean
130 get_changesubject : function (Room) : boolean
131 set_changesubject : function (Room, boolean) : boolean
132 get_subject : function (Room) : string
133 set_subject : function (Room, string) : boolean
134 get_historylength : function (Room) : integer
135 set_historylength : function (Room, integer) : boolean
136 get_presence_broadcast : function (Room) : { Role : boolean }
137 set_presence_broadcast : function (Room, { Role : boolean }) : boolean
138
139 is_anonymous_for : function (Room, jid : string) : boolean
140 get_salt : function (Room) : string
141 get_occupant_id : function (Room, Occupant)
142
143 -- Room teardown
144 clear : function (Room, x : Stanza)
145 destroy : function (Room, newjid : string, reason : string, password : string) : boolean
146
147 -- Room state persistence
148 record FrozenRoom
149 _jid : string
150 _data : { string : any }
151 _affiliation_data : { string : { string : any } }
152 -- { string : Affiliation }
153 end
154
155 record StateEntry
156 bare_jid : string
157 role : Role
158 jid : string
159 end
160
161 save : function (Room, forced : boolean, savestate : boolean) : boolean
162 freeze : function (Room, live : boolean) : FrozenRoom, { string : StateEntry }
163 end