Ghost/core/server/models
Kevin Ansfield 322664a145
Added ability to send a newsletter to members with a certain label or product (#12932)
refs https://github.com/TryGhost/Team/issues/581
refs https://github.com/TryGhost/Team/issues/582

When publishing a post via the API it was possible to send it using `?email_recipient_filter=all/free/paid` which allowed you to send to members only based on their payment status which is quite limiting for some sites.

This PR updates the `?email_recipient_filter` query param to support Ghost's `?filter` param syntax which enables more specific recipient lists, eg:

`?email_recipient_filter=status:free` = free members only
`?email_recipient_filter=status:paid` = paid members only
`?email_recipient_filter=label:vip` = members that have the `vip` label attached
`?email_recipient_filter=status:paid,label:vip` = paid members and members that have the `vip` label attached

The older `free/paid` values are still supported by the API for backwards compatibility.

- updates `Post` and `Email` models to transform legacy `free` and `paid` values to their NQL equivalents on read/write
  - lets us not worry about supporting legacy values elsewhere in the code
  - cleanup migration to transform all rows slated for 5.0
- removes schema and API `isIn` validations for recipient filters so allow free-form filters
- updates posts API input serializers to transform `free` and `paid` values in the `?email_recipient_filter` param to their NQL equivalents for backwards compatibility
- updates Post API controllers `edit` methods to run a query using the supplied filter to verify that it's valid
- updates `mega` service to use the filter directly when selecting recipients
2021-05-07 11:56:41 +01:00
..
base Moved i18n to shared 2021-05-04 13:03:38 +01:00
plugins Moved i18n to shared 2021-05-04 13:03:38 +01:00
relations Improved single author deprecated notices 2021-05-04 17:11:12 +01:00
action.js Added model implementation for actions 2019-02-06 21:36:09 +01:00
api-key.js Added the user_id field to the api_keys table 2020-11-20 09:53:18 +01:00
author.js Added plugin based author and public tag models in API v2 (#10284) 2019-01-03 20:30:35 +01:00
email-batch.js Fixed creation of EmailBatch and EmailRecipient collections 2020-10-14 15:11:45 +01:00
email-recipient.js Removed unnecessary bookshelf-relations config in EmailRecipient model 2021-01-05 15:28:30 +00:00
email.js Added ability to send a newsletter to members with a certain label or product (#12932) 2021-05-07 11:56:41 +01:00
index.js Added models for stripe prices and products 2021-04-12 21:53:59 +05:30
integration.js Updated host config to correctly use camelCase 2021-03-04 11:39:32 +00:00
invite.js Moved i18n to shared 2021-05-04 13:03:38 +01:00
label.js Moved i18n to shared 2021-05-04 13:03:38 +01:00
member-email-change-event.js Added member relation to events (#12656) 2021-02-16 16:14:20 +00:00
member-login-event.js Added member relation to events (#12656) 2021-02-16 16:14:20 +00:00
member-paid-subscription-event.js Added member relation to events (#12656) 2021-02-16 16:14:20 +00:00
member-payment-event.js Added member relation to events (#12656) 2021-02-16 16:14:20 +00:00
member-status-event.js Fixed member status events query 2021-02-18 18:11:50 +05:30
member-stripe-customer.js Added error handling for failed member imports 2020-08-26 17:11:35 +12:00
member-subscribe-event.js Added member relation to events (#12656) 2021-02-16 16:14:20 +00:00
member.js Added Product model and Member model relation (#12859) 2021-04-08 18:01:49 +01:00
mobiledoc-revision.js Added mobiledoc revisions functionality 2018-10-09 15:31:09 +02:00
permission.js Updated var declarations to const/let and no lists 2020-04-29 16:51:13 +01:00
post.js Added ability to send a newsletter to members with a certain label or product (#12932) 2021-05-07 11:56:41 +01:00
posts-meta.js 🐛 Fixed performance regression introduced in 4.1.0 (#12807) 2021-03-23 09:11:24 +00:00
product.js Added Product, StripeProduct & StripePrice relations (#12877) 2021-04-14 19:20:39 +01:00
role.js Moved i18n to shared 2021-05-04 13:03:38 +01:00
session.js Removed user_id constraint when upserting session (#10085) 2018-10-30 16:15:48 +07:00
settings.js Moved i18n to shared 2021-05-04 13:03:38 +01:00
single-use-token.js 🐛 Added multiple use grace period to tokens (#12519) 2021-01-18 17:03:41 +00:00
snippet.js 🐛 Fixed performance regression introduced in 4.1.0 (#12807) 2021-03-23 09:11:24 +00:00
stripe-customer-subscription.js Updated price serialisation on subscription 2021-05-07 15:15:10 +05:30
stripe-price.js Added models for stripe prices and products 2021-04-12 21:53:59 +05:30
stripe-product.js Added Product, StripeProduct & StripePrice relations (#12877) 2021-04-14 19:20:39 +01:00
tag-public.js Added plugin based author and public tag models in API v2 (#10284) 2019-01-03 20:30:35 +01:00
tag.js Moved i18n to shared 2021-05-04 13:03:38 +01:00
user.js Moved i18n to shared 2021-05-04 13:03:38 +01:00
webhook.js Bumped webhook API defaults to v4 2021-03-02 12:31:52 +13:00