Mercurial > prosody-hg
comparison plugins/muc/history.lib.lua @ 11120:b2331f3dfeea
Merge 0.11->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 30 Sep 2020 09:50:33 +0100 |
| parents | 1641e33f1d36 |
| children | ab820b2ad199 |
comparison
equal
deleted
inserted
replaced
| 11119:68df52bf08d5 | 11120:b2331f3dfeea |
|---|---|
| 46 | 46 |
| 47 module:hook("muc-config-form", function(event) | 47 module:hook("muc-config-form", function(event) |
| 48 table.insert(event.form, { | 48 table.insert(event.form, { |
| 49 name = "muc#roomconfig_historylength"; | 49 name = "muc#roomconfig_historylength"; |
| 50 type = "text-single"; | 50 type = "text-single"; |
| 51 datatype = "xs:integer"; | |
| 51 label = "Maximum number of history messages returned by room"; | 52 label = "Maximum number of history messages returned by room"; |
| 52 desc = "Specify the maximum number of previous messages that should be sent to users when they join the room"; | 53 desc = "Specify the maximum number of previous messages that should be sent to users when they join the room"; |
| 53 value = tostring(get_historylength(event.room)); | 54 value = get_historylength(event.room); |
| 54 }); | 55 }); |
| 55 table.insert(event.form, { | 56 table.insert(event.form, { |
| 56 name = 'muc#roomconfig_defaulthistorymessages', | 57 name = 'muc#roomconfig_defaulthistorymessages', |
| 57 type = 'text-single', | 58 type = 'text-single', |
| 59 datatype = "xs:integer"; | |
| 58 label = 'Default number of history messages returned by room', | 60 label = 'Default number of history messages returned by room', |
| 59 desc = "Specify the number of previous messages sent to new users when they join the room"; | 61 desc = "Specify the number of previous messages sent to new users when they join the room"; |
| 60 value = tostring(get_defaulthistorymessages(event.room)) | 62 value = get_defaulthistorymessages(event.room); |
| 61 }); | 63 }); |
| 62 end, 70-5); | 64 end, 70-5); |
| 63 | 65 |
| 64 module:hook("muc-config-submitted/muc#roomconfig_historylength", function(event) | 66 module:hook("muc-config-submitted/muc#roomconfig_historylength", function(event) |
| 65 if set_historylength(event.room, event.value) then | 67 if set_historylength(event.room, event.value) then |
| 196 module:fire_event("muc-add-history", event); | 198 module:fire_event("muc-add-history", event); |
| 197 end | 199 end |
| 198 end); | 200 end); |
| 199 | 201 |
| 200 module:hook("muc-message-is-historic", function (event) | 202 module:hook("muc-message-is-historic", function (event) |
| 201 return event.stanza:get_child("body"); | 203 local stanza = event.stanza; |
| 204 if stanza:get_child("no-store", "urn:xmpp:hints") | |
| 205 or stanza:get_child("no-permanent-store", "urn:xmpp:hints") then | |
| 206 -- XXX Experimental XEP | |
| 207 return false, "hint"; | |
| 208 end | |
| 209 if stanza:get_child("store", "urn:xmpp:hints") then | |
| 210 return true, "hint"; | |
| 211 end | |
| 212 if stanza:get_child("body") then | |
| 213 return true; | |
| 214 end | |
| 215 if stanza:get_child("encryption", "urn:xmpp:eme:0") then | |
| 216 -- Since we can't know what an encrypted message contains, we assume it's important | |
| 217 -- XXX Experimental XEP | |
| 218 return true, "encrypted"; | |
| 219 end | |
| 220 if stanza:get_child(nil, "urn:xmpp:chat-markers:0") then | |
| 221 -- XXX Experimental XEP | |
| 222 return true, "marker"; | |
| 223 end | |
| 202 end, -1); | 224 end, -1); |
| 203 | 225 |
| 204 return { | 226 return { |
| 205 set_max_length = set_max_history_length; | 227 set_max_length = set_max_history_length; |
| 206 parse_history = parse_history; | 228 parse_history = parse_history; |
