Mercurial > prosody-hg
annotate plugins/muc/affiliation_notify.lib.lua @ 8942:ecb5e13d97bb
MUC: Remove 'affiliation notify' config option, as it's irrelevant to room owners, always notify instead
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 27 Jun 2018 15:25:35 +0100 |
| parents | 3d17b2bf0e0c |
| children | 3a416b866c94 |
| rev | line source |
|---|---|
|
6394
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
1 -- Prosody IM |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
2 -- Copyright (C) 2014 Daurnimator |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
3 -- |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
4 -- This project is MIT/X11 licensed. Please see the |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
5 -- COPYING file in the source package for more information. |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
6 -- |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
7 |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
8 --[[ |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
9 Out of courtesy, a MUC service MAY send an out-of-room <message/> |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
10 if a user's affiliation changes while the user is not in the room; |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
11 the message SHOULD be sent from the room to the user's bare JID, |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
12 MAY contain a <body/> element describing the affiliation change, |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
13 and MUST contain a status code of 101. |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
14 ]] |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
15 |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
16 |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
17 local st = require "util.stanza"; |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
18 |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
19 module:hook("muc-set-affiliation", function(event) |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
20 local room = event.room; |
|
8942
ecb5e13d97bb
MUC: Remove 'affiliation notify' config option, as it's irrelevant to room owners, always notify instead
Matthew Wild <mwild1@gmail.com>
parents:
7990
diff
changeset
|
21 if not event.in_room then |
|
6394
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
22 local body = string.format("Your affiliation in room %s is now %s.", room.jid, event.affiliation); |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
23 local stanza = st.message({ |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
24 type = "headline"; |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
25 from = room.jid; |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
26 to = event.jid; |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
27 }, body) |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
28 :tag("x", {xmlns = "http://jabber.org/protocol/muc#user"}) |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
29 :tag("status", {code="101"}):up() |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
30 :up(); |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
31 room:route_stanza(stanza); |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
32 end |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
33 end); |
