author | Kim Alvefur <zash@zash.se> |
Wed, 27 Jun 2018 17:35:20 +0200 | |
changeset 3157 | e0de1fdbc80a |
parent 3156 | 882f7d5c3ce8 |
child 3260 | 0992c0398783 |
permissions | -rw-r--r-- |
3104 | 1 |
# Introduction |
2 |
||
3 |
Lets you easily publish data to PubSub using a HTTP POST request. The |
|
4 |
payload can be Atom feeds, arbitrary XML, or arbitrary JSON. The type |
|
5 |
should be indicated via the `Content-Type` header. |
|
6 |
||
7 |
``` {.bash} |
|
8 |
curl http://localhost:5280/pubsub_post/princely_musings \ |
|
9 |
-H "Content-Type: application/json" \ |
|
10 |
--data-binary '{"musing":"To be, or not to be: that is the question"}' |
|
11 |
``` |
|
12 |
||
3157
e0de1fdbc80a
mod_pubsub_post/README: Describe what happens to different data types
Kim Alvefur <zash@zash.se>
parents:
3156
diff
changeset
|
13 |
- JSON data is wrapped in a [XEP-0335] container. |
e0de1fdbc80a
mod_pubsub_post/README: Describe what happens to different data types
Kim Alvefur <zash@zash.se>
parents:
3156
diff
changeset
|
14 |
- An Atom feed may have many `<entry>` and each one is published as |
e0de1fdbc80a
mod_pubsub_post/README: Describe what happens to different data types
Kim Alvefur <zash@zash.se>
parents:
3156
diff
changeset
|
15 |
its own PubSub item. |
e0de1fdbc80a
mod_pubsub_post/README: Describe what happens to different data types
Kim Alvefur <zash@zash.se>
parents:
3156
diff
changeset
|
16 |
- Other XML is simply published to a randomly named item as-is. |
e0de1fdbc80a
mod_pubsub_post/README: Describe what happens to different data types
Kim Alvefur <zash@zash.se>
parents:
3156
diff
changeset
|
17 |
|
3104 | 18 |
# Configuration |
19 |
||
20 |
## Authentication |
|
21 |
||
22 |
Authentication can be handled in two different ways. |
|
23 |
||
24 |
### None |
|
25 |
||
26 |
``` {.lua} |
|
27 |
pubsub_post_actor = "superuser" |
|
28 |
``` |
|
29 |
||
30 |
The module uses an internal actor that has all privileges and can always |
|
31 |
do everything. It is strongly suggested that you do not expose this to |
|
32 |
the Internet. *Maybe* it shouldn't be the default... |
|
33 |
||
34 |
### IP |
|
35 |
||
36 |
``` {.lua} |
|
37 |
pubsub_post_actor = "request.ip" |
|
38 |
``` |
|
39 |
||
40 |
Uses the IP address from the HTTP request as actor, which means this |
|
41 |
pseudo-JID must be given a 'publisher' affiliation. This should work |
|
42 |
nicely with the `autocreate_on_publish` setting, where the first actor |
|
43 |
to attempt to publish to a non-existant node becomes owner of it, which |
|
44 |
includes publishing rights. |
|
45 |
||
3156
882f7d5c3ce8
mod_pubsub_post/README: Affiliation management in trunk now
Kim Alvefur <zash@zash.se>
parents:
3155
diff
changeset
|
46 |
Prosodys PubSub module supports [setting affiliations via |
882f7d5c3ce8
mod_pubsub_post/README: Affiliation management in trunk now
Kim Alvefur <zash@zash.se>
parents:
3155
diff
changeset
|
47 |
XMPP](https://xmpp.org/extensions/xep-0060.html#owner-affiliations), in |
882f7d5c3ce8
mod_pubsub_post/README: Affiliation management in trunk now
Kim Alvefur <zash@zash.se>
parents:
3155
diff
changeset
|
48 |
trunk since [revision |
882f7d5c3ce8
mod_pubsub_post/README: Affiliation management in trunk now
Kim Alvefur <zash@zash.se>
parents:
3155
diff
changeset
|
49 |
384ef9732b81](https://hg.prosody.im/trunk/rev/384ef9732b81). |
3104 | 50 |
|
51 |
It can however be done from another plugin: |
|
52 |
||
53 |
``` {.lua} |
|
54 |
local mod_pubsub = module:depends("pubsub"); |
|
55 |
local pubsub = mod_pubsub.service; |
|
56 |
||
57 |
pubsub:create("princely_musings", true); |
|
58 |
pubsub:set_affiliation("princely_musings", true, "127.0.0.1", "publisher"); |
|
59 |
``` |