Mercurial > prosody-modules
comparison mod_http_roster_admin/README.markdown @ 3007:af1b3cef52e1
mod_http_roster_admin: Add syntax highlighting hints
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 30 Apr 2018 01:49:59 +0200 |
parents | e6f91e00b507 |
children |
comparison
equal
deleted
inserted
replaced
3006:e6f91e00b507 | 3007:af1b3cef52e1 |
---|---|
19 This module relies on `mod_storage_memory` and `mod_block_subscriptions`. | 19 This module relies on `mod_storage_memory` and `mod_block_subscriptions`. |
20 | 20 |
21 In `.parts/prosody/etc/prosody/prosody.cfg.lua`, where your particular | 21 In `.parts/prosody/etc/prosody/prosody.cfg.lua`, where your particular |
22 `VirtualHost` is being configured, add the following: | 22 `VirtualHost` is being configured, add the following: |
23 | 23 |
24 modules_enabled = { | 24 ``` lua |
25 "http_roster_admin", | 25 modules_enabled = { |
26 "block_subscriptions", | 26 "http_roster_admin", |
27 "storage_memory", | 27 "block_subscriptions", |
28 "http_files" | 28 "storage_memory", |
29 } | 29 "http_files" |
30 modules_disabled = { | 30 } |
31 -- Prosody will get the roster from the backend app, | 31 modules_disabled = { |
32 -- so we disable the default roster module. | 32 -- Prosody will get the roster from the backend app, |
33 "roster" | 33 -- so we disable the default roster module. |
34 } | 34 "roster" |
35 storage = { roster = "memory" } | 35 } |
36 http_roster_url = "http://localhost/contacts/%s" -- %s will be replaced by an URL-encoded username | 36 storage = { roster = "memory" } |
37 http_roster_url = "http://localhost/contacts/%s" -- %s will be replaced by an URL-encoded username | |
38 ``` | |
37 | 39 |
38 The `http_roster_url` parameter needs to be configured to point to the | 40 The `http_roster_url` parameter needs to be configured to point to the |
39 URL in the backend application which returns users' contacts rosters. | 41 URL in the backend application which returns users' contacts rosters. |
40 | 42 |
41 In this URL, the pattern `%s` is replaced by an URL-encoded username. | 43 In this URL, the pattern `%s` is replaced by an URL-encoded username. |
62 value is data about that contact. | 64 value is data about that contact. |
63 | 65 |
64 If the user 'john' has friends 'marie' and 'michael', the web app would return a HTTP '200 OK' response | 66 If the user 'john' has friends 'marie' and 'michael', the web app would return a HTTP '200 OK' response |
65 with the following contents: | 67 with the following contents: |
66 | 68 |
67 { | 69 ``` json |
68 "marie@example.com": { | 70 { |
69 "name": "Marie" | 71 "marie@example.com": { |
70 }, | 72 "name": "Marie" |
71 | 73 }, |
72 "michael@example.com": { | 74 |
73 "name": "Michael" | 75 "michael@example.com": { |
74 } | 76 "name": "Michael" |
75 } | 77 } |
78 } | |
79 ``` | |
76 | 80 |
77 ### Notifying Prosody of roster changes | 81 ### Notifying Prosody of roster changes |
78 | 82 |
79 The external service needs to notify Prosody whenever a user's roster | 83 The external service needs to notify Prosody whenever a user's roster |
80 changes. To do this, it must make an HTTP POST request to either: | 84 changes. To do this, it must make an HTTP POST request to either: |
93 rosters have changed. | 97 rosters have changed. |
94 | 98 |
95 For example, if user ‘john’ became friends with ‘aaron’, both john’s | 99 For example, if user ‘john’ became friends with ‘aaron’, both john’s |
96 contact list and aaron’s contact lists have changed: | 100 contact list and aaron’s contact lists have changed: |
97 | 101 |
98 ["john", "aaron"] | 102 ``` json |
103 ["john", "aaron"] | |
104 ``` | |
99 | 105 |
100 When the operation is complete Prosody will reply with a summary of the | 106 When the operation is complete Prosody will reply with a summary of the |
101 operation - a JSON object containing: | 107 operation - a JSON object containing: |
102 | 108 |
103 - **status**: either “ok” (success) or “error” (operation completely failed) | 109 - **status**: either “ok” (success) or “error” (operation completely failed) |
105 - **updated**: The number of rosters successfully updated | 111 - **updated**: The number of rosters successfully updated |
106 - **errors**: The number of rosters that failed to update | 112 - **errors**: The number of rosters that failed to update |
107 | 113 |
108 Example: | 114 Example: |
109 | 115 |
110 { | 116 ``` json |
111 "status": "ok", | 117 { |
112 "message": "roster update complete", | 118 "status": "ok", |
113 "updated": 2, | 119 "message": "roster update complete", |
114 "errors": 0 | 120 "updated": 2, |
115 } | 121 "errors": 0 |
122 } | |
123 ``` | |
116 | 124 |
117 Prosody may also return status codes `400` or `500` in case of errors (such | 125 Prosody may also return status codes `400` or `500` in case of errors (such |
118 as a missing/malformed body). | 126 as a missing/malformed body). |