Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
f-w committed Oct 22, 2023
1 parent 96ac13c commit 680534d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions docs/docs/api/subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,20 @@ POST /subscriptions

1. inputs are validated. If validation fails, error is returned.
2. for user requests, the _state_ field is forced to _unconfirmed_
3. for authenticated user request, _userId_ field is populated with authenticated userId
4. otherwise, _unsubscriptionCode_ is generated if config _subscription.anonymousUnsubscription.code.required_ is _true_, unless if the request is made by admin and the field is already populated
5. if _confirmationRequest.confirmationCodeEncrypted_ is populated, a confirmation code is generated by decrypting this field using private RSA key, then put decrypted confirmation code to field _confirmationRequest.confirmationCode_
6. otherwise, for user requests and for admin requests missing message template, the message template is set to configured value. Then, if _confirmationRequest.confirmationCodeRegex_ is populated, a confirmation code is generated conforming to regex and put to field _confirmationRequest.confirmationCode_
7. the subscription request is saved to database.
8. if _confirmationRequest.sendRequest_ is true, then a message is sent to _userChannelId_. The message template is determined by
3. for anonymous user request, _data_ field is deleted
4. for authenticated user request, _userId_ field is populated with authenticated userId
5. otherwise, _unsubscriptionCode_ is generated if config _subscription.anonymousUnsubscription.code.required_ is _true_, unless if the request is made by admin and the field is already populated
6. if _confirmationRequest.confirmationCodeEncrypted_ is populated, a confirmation code is generated by decrypting this field using private RSA key, then put decrypted confirmation code to field _confirmationRequest.confirmationCode_
7. otherwise, for user requests and for admin requests missing message template, the message template is set to configured value. Then, if _confirmationRequest.confirmationCodeRegex_ is populated, a confirmation code is generated conforming to regex and put to field _confirmationRequest.confirmationCode_
8. the subscription request is saved to database.
9. if _confirmationRequest.sendRequest_ is true, then a message is sent to _userChannelId_. The message template is determined by

1. if _detectDuplicatedSubscription_ is true and there is already a confirmed subscription to the same _serviceName_, _channel_ and _userChannelId_, then message is sent using _duplicatedSubscriptionNotification_ as template;
2. otherwise, a confirmation request is sent to using the template fields in _confirmationRequest_.

[Mail merge](../overview/#mail-merge) is performed on the template regardless.

9. The subscription data, including auto-generated id, is returned as response unless there is error when sending confirmation request or saving to database. For user request, some fields containing sensitive information such as _confirmationRequest_ are removed prior to sending the response.
10. The subscription data, including auto-generated id, is returned as response unless there is error when sending confirmation request or saving to database. For user request, some fields containing sensitive information such as _confirmationRequest_ are removed prior to sending the response.

- examples

Expand Down

0 comments on commit 680534d

Please sign in to comment.