Software / code / prosody
Annotate
plugins/muc/affiliation_notify.lib.lua @ 8943:3a416b866c94
MUC: Remove text body from affiliation change notification
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 27 Jun 2018 15:28:45 +0100 |
| parent | 8942:ecb5e13d97bb |
| 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 stanza = st.message({ |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
23 type = "headline"; |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
24 from = room.jid; |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
25 to = event.jid; |
|
8943
3a416b866c94
MUC: Remove text body from affiliation change notification
Matthew Wild <mwild1@gmail.com>
parents:
8942
diff
changeset
|
26 }) |
|
6394
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
27 :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
|
28 :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
|
29 :up(); |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
30 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
|
31 end |
|
fe034fa564ee
plugins/muc: Add affiliation_notify config option to send out status code 101
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
32 end); |