@@ -31,10 +31,11 @@ endpoint restrictions, placeholders, flexible configuration
3131- [ Getting Started] ( #getting-started )
3232- [ Setup] ( #setup )
3333- [ Usage] ( #usage )
34- - [ Best Practices] ( #security- best-practices )
34+ - [ Best Practices] ( #best-practices )
3535- [ Configuration] ( #configuration )
3636 - [ Endpoints] ( #endpoints )
3737 - [ Variables] ( #variables )
38+ - [ Data Aliases] ( #data-aliases )
3839 - [ Message Templates] ( #message-templates )
3940- [ Contributing] ( #contributing )
4041- [ Support] ( #support )
@@ -66,9 +67,10 @@ services:
6667 container_name : secured-signal
6768 environment :
6869 API__URL : http://signal-api:8080
69- SETTINGS__VARIABLES__RECIPIENTS : " [+123400002, +123400003, +123400004]"
70+ SETTINGS__VARIABLES__RECIPIENTS :
71+ ' [+123400002, +123400003, +123400004]'
7072 SETTINGS__VARIABLES__NUMBER : " +123400001"
71- API__TOKENS : " [LOOOOOONG_STRING]"
73+ API__TOKENS : ' [LOOOOOONG_STRING]'
7274 ports :
7375 - " 8880:8880"
7476 restart : unless-stopped
@@ -100,9 +102,10 @@ services:
100102 container_name: secured-signal
101103 environment:
102104 API__URL: http://signal-api:8080
103- SETTINGS__VARIABLES__RECIPIENTS: "[+123400002,+123400003,+123400004]"
105+ SETTINGS__VARIABLES__RECIPIENTS:
106+ '[+123400002,+123400003,+123400004]'
104107 SETTINGS__VARIABLES__NUMBER: "+123400001"
105- API__TOKENS: " [LOOOOOONG_STRING]"
108+ API__TOKENS: ' [LOOOOOONG_STRING]'
106109 labels:
107110 - traefik.enable=true
108111 - traefik.http.routers.signal-api.rule=Host(` signal-api.mydomain.com`)
@@ -238,31 +241,24 @@ curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer API_T
238241
239242#### Placeholders
240243
241- If you are not comfortable / don't want to hardcode your Number for example and/or Recipients in you, may use ** Placeholders** in your Request. See [ Custom Variables ] ( #variables ) .
244+ If you are not comfortable / don't want to hardcode your Number for example and/or Recipients in you, may use ** Placeholders** in your Request.
242245
243- These Placeholders can be used in the Request Query or the Body of a Request like so:
246+ You can use [ ** Variable ** ] ( #variables ) ` {{.NUMBER}} ` Placeholders and ** Body** Placeholders ` {{@data.key}} ` .
244247
245- ** Body**
248+ | Type | Example |
249+ | :---- | :--------------------------------------------------------------- |
250+ | Body | ` {"number": "{{ .NUMBER }}", "recipients": "{{ .RECIPIENTS }}"} ` |
251+ | Query | ` http://sec-signal-api:8880/v1/receive/?@number={{.NUMBER}} ` |
252+ | Path | ` http://sec-signal-api:8880/v1/receive/{{.NUMBER}} ` |
253+
254+ You can also combine them:
246255
247256``` json
248257{
249- "number" : " {{ .NUMBER }}" ,
250- "recipients" : " {{ .RECIPIENTS }}"
258+ "content" : " {{.NUMBER}} -> {{.RECIPIENTS}}"
251259}
252260```
253261
254- ** Query**
255-
256- ```
257- http://sec-signal-api:8880/v1/receive/?@number={{.NUMBER}}
258- ```
259-
260- ** Path**
261-
262- ```
263- http://sec-signal-api:8880/v1/receive/{{.NUMBER}}
264- ```
265-
266262#### KeyValue Pair Injection
267263
268264In some cases you may not be able to access / modify the Request Body, in that case specify needed values in the Request Query:
@@ -272,7 +268,7 @@ In some cases you may not be able to access / modify the Request Body, in that c
272268In order to differentiate Injection Queries and _ regular_ Queries
273269you have to add ` @ ` in front of any KeyValue Pair assignment.
274270
275- Supported types include ** strings** , ** ints** and ** arrays ** . See [ Formatting] ( #string-to-type ) .
271+ Supported types include ** strings** , ** ints** , ** arrays ** and ** json dictionaries ** . See [ Formatting] ( #string-to-type ) .
276272
277273## Best Practices
278274
@@ -295,20 +291,28 @@ This example config shows all of the individual settings that can be applied:
295291
296292``` yaml
297293# Example Config (all configurations shown)
294+ service :
295+ port : 8880
298296
299297api :
300- port : 8880
301298 url : http://signal-api:8080
302299 tokens : [token1, token2]
303300
304- logLevel : INFO
301+ logLevel : info
305302
306303settings :
304+ messageTemplate : |
305+ You've got a Notification:
306+ {{}}
307+ At {{.timestamp}} on {{.date}}.
308+ Send using {{.NUMBER}}.
309+
307310 variables :
308311 number : " +123400001"
309312 recipients : ["+123400002", "group.id", "user.id"]
310313
311- messageAliases : [{ alias: "msg", score: 100 }]
314+ dataAliases :
315+ " " : [{ alias: "msg", score: 100 }]
312316
313317 blockedEndpoints :
314318 - /v1/about
@@ -437,9 +441,61 @@ settings:
437441 recipients: ["+123400002", "group.id", "user.id"]
438442` ` `
439443
444+ # ## Message Templates
445+
446+ To customize the `message` attribute you can use **Message Templates** to build your message by using other Body Keys and Variables.
447+ Use `messageTemplate` to configure :
448+
449+ ` ` ` yaml
450+ settings:
451+ messageTemplate: |
452+ Your Message:
453+ {{@message}}.
454+ Sent with Secured Signal API.
455+ ` ` `
456+
457+ Use `{{@data.key}}` to reference Body Keys and `{{.KEY}}` for Variables.
458+
459+ # ## Data Aliases
460+
461+ To improve compatibility with other services Secured Signal API provides **Data Aliases** and a built-in `message` Alias.
462+
463+ <details>
464+ <summary><strong>Default `message` Aliases</strong></summary>
465+
466+ | Alias | Score | Alias | Score |
467+ | ------------ | ----- | ---------------- | ----- |
468+ | msg | 100 | data.content | 9 |
469+ | content | 99 | data.description | 8 |
470+ | description | 98 | data.text | 7 |
471+ | text | 20 | data.summary | 6 |
472+ | summary | 15 | data.details | 5 |
473+ | details | 14 | body | 2 |
474+ | data.message | 10 | data | 1 |
475+
476+ </details>
477+
478+ Secured Signal API will pick the best scoring Data Alias (if available) to extract set the Key to the correct Value from the Request Body.
479+
480+ Data Aliases can be added by setting `dataAliases` in your config :
481+
482+ ` ` ` yaml
483+ settings:
484+ dataAliases:
485+ "@message":
486+ [
487+ { alias: "msg", score: 80 },
488+ { alias: "data.message", score: 79 },
489+ { alias: "array[0].message", score: 78 },
490+ ]
491+ ".NUMBER": [{ alias: "phone_number", score: 100 }]
492+ ` ` `
493+
494+ Use `@` for aliasing Body Keys and `.` for aliasing Variables.
495+
440496# ## Port
441497
442- To change the Port which Secured Signal API uses, you need to set `server .port` in your config. (default : ` 8880` )
498+ To change the Port which Secured Signal API uses, you need to set `service .port` in your config. (default : ` 8880` )
443499
444500# ## Log Level
445501
0 commit comments