Software /
code /
prosody
Annotate
plugins/muc/hidden.lib.lua @ 9034:1c709e3d2e5e
MUC: Improve labels of all config form items
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 13 Jul 2018 13:22:40 +0100 |
parent | 7401:e16b3fd0bd80 |
child | 9035:173c0e16e704 |
rev | line source |
---|---|
6225
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
1 -- Prosody IM |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
2 -- Copyright (C) 2008-2010 Matthew Wild |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
3 -- Copyright (C) 2008-2010 Waqas Hussain |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
4 -- Copyright (C) 2014 Daurnimator |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
5 -- |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
6 -- This project is MIT/X11 licensed. Please see the |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
7 -- COPYING file in the source package for more information. |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
8 -- |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
9 |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
10 local function get_hidden(room) |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
11 return room._data.hidden; |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
12 end |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
13 |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
14 local function set_hidden(room, hidden) |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
15 hidden = hidden and true or nil; |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
16 if get_hidden(room) == hidden then return false; end |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
17 room._data.hidden = hidden; |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
18 return true; |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
19 end |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
20 |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
21 module:hook("muc-config-form", function(event) |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
22 table.insert(event.form, { |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
23 name = "muc#roomconfig_publicroom"; |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
24 type = "boolean"; |
9034
1c709e3d2e5e
MUC: Improve labels of all config form items
Matthew Wild <mwild1@gmail.com>
parents:
7401
diff
changeset
|
25 label = "Include room in public lists"; |
1c709e3d2e5e
MUC: Improve labels of all config form items
Matthew Wild <mwild1@gmail.com>
parents:
7401
diff
changeset
|
26 desc = "Enable this to allow people to find the room"; |
6225
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
27 value = not get_hidden(event.room); |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
28 }); |
7401
e16b3fd0bd80
MUC: Assign priorities to config form hooks so they have a consistent order on each start
Kim Alvefur <zash@zash.se>
parents:
7353
diff
changeset
|
29 end, 100-5); |
6225
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
30 |
6991
84e01dbb739e
MUC: Update all config form handlers to take advantage of the new per-option events
Matthew Wild <mwild1@gmail.com>
parents:
6225
diff
changeset
|
31 module:hook("muc-config-submitted/muc#roomconfig_publicroom", function(event) |
84e01dbb739e
MUC: Update all config form handlers to take advantage of the new per-option events
Matthew Wild <mwild1@gmail.com>
parents:
6225
diff
changeset
|
32 if set_hidden(event.room, not event.value) then |
6225
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
33 event.status_codes["104"] = true; |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
34 end |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
35 end); |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
36 |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
37 module:hook("muc-disco#info", function(event) |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
38 event.reply:tag("feature", {var = get_hidden(event.room) and "muc_hidden" or "muc_public"}):up(); |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
39 end); |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
40 |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
41 return { |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
42 get = get_hidden; |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
43 set = set_hidden; |
12537f1c1fec
plugins/muc: Move 'hidden' ('public') code to own file
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
44 }; |