Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] preconfirm_subscriptions is ignored for PUT requests #604

Closed
marcinkunert opened this issue Nov 29, 2021 · 2 comments
Closed

[API] preconfirm_subscriptions is ignored for PUT requests #604

marcinkunert opened this issue Nov 29, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@marcinkunert
Copy link
Contributor

Version:

  • listmonk: v2.0.0
  • OS: Docker/Debian

Description of the bug and steps to reproduce:

  1. Create a subscription (status: confirmed)
  2. User unsubscribes (status: unsubscribed)
  3. Send API PUT request to /subscribers/:id with preconfirm_subscriptions set to true

Expected behavior:
User is set back to confirmed status

Actual behavior:
Status of the subscription doesn't change.

Workaround:
Let's say the ID of the target list is 4.

  1. Send API request to sign the user to any other list (e.g. 1)
  2. Send API request to sign the user to the target list (4)

Concerns

Let's say the user is signed up to multiple lists:

1 - newsletter - status: unsubscribed
2 - marketing - status: unsubscribed

To use a specific part of my service, the user has to agree to receive marketing emails. Currently, there is no option to change only one of these statuses. It's either change them all (by using the workaround I've described) or none. Even if the behavior with preconfirm_subscriptions would change that would mean that the user will be subscribed to both list.

Possible solutions:

  • change the API so instead of receiving only a list of IDs for target lists it would also get the expected status. In such case preconfirm_subscriptions would be no longer needed. This solution would break the current API
  • add an API for managing lists for given subscriber. E.g. /api/subscribers/:id/lists/
@marcinkunert marcinkunert added the bug Something isn't working label Nov 29, 2021
@knadh
Copy link
Owner

knadh commented Nov 29, 2021

add an API for managing lists for given subscriber. E.g. /api/subscribers/:id/lists

I think this is the best approach. preconfirm_subscriptions is only meant to apply to new lists that are being added, which is the current behaviour. I'll push a patch soon.

@knadh knadh added enhancement New feature or request and removed bug Something isn't working labels Nov 30, 2021
@knadh knadh self-assigned this Dec 1, 2021
@knadh knadh closed this as completed in 48ef3dc Feb 4, 2022
@knadh
Copy link
Owner

knadh commented Feb 4, 2022

curl 'http://localhost:8080/api/subscribers/lists' -X PUT \
      -H 'Content-Type: application/json;charset=utf-8' \
      --data-raw '{"action":"add", "status": "confirmed", "target_list_ids":[2],"ids":[1]}'

Added status=confirmed|unconfirmed|unsubscribed to the existing bulk list modification API.

Just realised, this long forgotten API's URI + fields are a bit awkward and not consistent with the rest of the APIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants