Ghost/ghost/admin/app/adapters/post.js
Simon Backx 98e80cb6f8 Replaced newsletterId usage with newsletter
refs https://github.com/TryGhost/Team/issues/1569
refs https://github.com/TryGhost/Team/issues/1596
refs https://github.com/TryGhost/Team/issues/1576

- Removed some usages of post.newsletterId with post.newsletter
- Renamed newsletterId adapterOption from newsletterId to newsletter, in preparation of https://github.com/TryGhost/Team/issues/1596 (still sending newsletter_id)
- Removed newsletterId property of post model
2022-05-10 13:56:30 +02:00

34 lines
1.3 KiB
JavaScript

import ApplicationAdapter from 'ghost-admin/adapters/application';
export default class Post extends ApplicationAdapter {
// posts and pages now include everything by default
buildIncludeURL(store, modelName, id, snapshot, requestType, query) {
const url = this.buildURL(modelName, id, snapshot, requestType, query);
const parsedUrl = new URL(url);
// TODO: cleanup sendEmailWhenPublished when removing publishingFlow flag
let emailRecipientFilter = snapshot?.adapterOptions?.emailRecipientFilter
|| snapshot?.adapterOptions?.sendEmailWhenPublished;
if (emailRecipientFilter) {
if (emailRecipientFilter === 'status:free,status:-free') {
emailRecipientFilter = 'all';
}
parsedUrl.searchParams.append('email_recipient_filter', emailRecipientFilter);
}
if (snapshot?.adapterOptions?.newsletter) {
// TODO: rename newsletter_id to newsletter once changed in the backend
const newsletterId = snapshot.adapterOptions.newsletter;
parsedUrl.searchParams.append('newsletter_id', newsletterId);
}
return parsedUrl.toString();
}
buildQuery(store, modelName, options) {
return options;
}
}