annotate mod_offline_hints/mod_offline_hints.lua @ 4326:f6fdefc5c6ac

mod_roster_command: Fix subscription when the "user JID" is a bare domain. Do not attempt to update the roster when the user is bare domain (e.g. a component), since they don't have rosters and the attempt results in an error: $ prosodyctl mod_roster_command subscribe proxy.example.com contact@example.com xxxxxxxxxxFailed to execute command: Error: /usr/lib/prosody/core/rostermanager.lua:104: attempt to concatenate local 'username' (a nil value) stack traceback: /usr/lib/prosody/core/rostermanager.lua:104: in function 'load_roster' /usr/lib/prosody/core/rostermanager.lua:305: in function 'set_contact_pending_out' mod_roster_command.lua:44: in function 'subscribe'
author Boris Grozev <boris@jitsi.org>
date Tue, 05 Jan 2021 13:15:00 -0600
parents e86315c9b5c4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3500
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
1 -- mod_offline_hints
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
2 --
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
3 -- Copyright (C) 2019 Marcos de Vera Piquero <marcos.devera@quobis.com>
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
4 --
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
5 -- This file is MIT/X11 licensed.
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
6 --
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
7 -- A module to discard hinted messages with no-store at mod_offline
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
8 --
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
9
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
10 module:depends"offline";
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
11
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
12 local function handle_offline (event)
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
13 local stanza = event.stanza;
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
14 if (stanza:get_child("no-store", "urn:xmpp:hints") or
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
15 stanza:get_child("no-permanent-store", "urn:xmpp:hints")) then
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
16 module:log("debug", "Not storing offline stanza: %s (urn:xmpp:hints)", stanza);
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
17 return false;
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
18 end
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
19 return nil;
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
20 end
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
21
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
22 module:hook("message/offline/handle", handle_offline);
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
23
e86315c9b5c4 offline_hints: discard no-store hinted messages at mod_offline
marc0s <marcos.devera@quobis.com>
parents:
diff changeset
24 module:log("debug", "Module loaded");