2019-02-25 17:55:55 +03:00
|
|
|
import ApplicationAdapter from 'ghost-admin/adapters/application';
|
|
|
|
|
2022-02-02 19:57:22 +03:00
|
|
|
export default class Post extends ApplicationAdapter {
|
2019-02-25 17:55:55 +03:00
|
|
|
// posts and pages now include everything by default
|
|
|
|
buildIncludeURL(store, modelName, id, snapshot, requestType, query) {
|
2022-04-06 12:22:00 +03:00
|
|
|
const url = this.buildURL(modelName, id, snapshot, requestType, query);
|
|
|
|
const parsedUrl = new URL(url);
|
2019-11-14 20:33:35 +03:00
|
|
|
|
2022-05-04 12:30:37 +03:00
|
|
|
// TODO: cleanup sendEmailWhenPublished when removing publishingFlow flag
|
|
|
|
let emailRecipientFilter = snapshot?.adapterOptions?.emailRecipientFilter
|
|
|
|
|| snapshot?.adapterOptions?.sendEmailWhenPublished;
|
2021-05-07 13:58:05 +03:00
|
|
|
|
2022-05-04 12:30:37 +03:00
|
|
|
if (emailRecipientFilter) {
|
2021-05-07 13:58:05 +03:00
|
|
|
if (emailRecipientFilter === 'status:free,status:-free') {
|
|
|
|
emailRecipientFilter = 'all';
|
|
|
|
}
|
|
|
|
|
|
|
|
parsedUrl.searchParams.append('email_recipient_filter', emailRecipientFilter);
|
2019-11-14 20:33:35 +03:00
|
|
|
}
|
|
|
|
|
2022-05-10 14:52:28 +03:00
|
|
|
if (snapshot?.adapterOptions?.newsletter) {
|
|
|
|
// TODO: rename newsletter_id to newsletter once changed in the backend
|
|
|
|
const newsletterId = snapshot.adapterOptions.newsletter;
|
2022-04-06 12:22:00 +03:00
|
|
|
parsedUrl.searchParams.append('newsletter_id', newsletterId);
|
|
|
|
}
|
|
|
|
|
2019-11-14 20:33:35 +03:00
|
|
|
return parsedUrl.toString();
|
2022-02-02 19:57:22 +03:00
|
|
|
}
|
2019-02-25 17:55:55 +03:00
|
|
|
|
|
|
|
buildQuery(store, modelName, options) {
|
|
|
|
return options;
|
|
|
|
}
|
2022-02-02 19:57:22 +03:00
|
|
|
}
|