Ghost/ghost/admin/app/adapters/post.js
Kevin Ansfield 6fe159c8d9 Updated handling of send_email_when_published
refs 5fd2b7fed1

- sends `?send_email_when_published=true` query param when scheduling/publishing a post with the toggle turned on
  - adds support to the posts adapter for handling the `adapterOptions` option
  - updates the editor `save` task to pass through the required adapter option when a post is being published or scheduled with the toggle checked
- moves state for the email toggle into the publish menu so that we don't try to toggle the model attribute which should only be fetched from the API
- prevent `post.send_email_when_published` being sent to the API via the serializer as it's now a read-only attribute
2019-11-14 17:33:35 +00:00

20 lines
674 B
JavaScript

import ApplicationAdapter from 'ghost-admin/adapters/application';
export default ApplicationAdapter.extend({
// posts and pages now include everything by default
buildIncludeURL(store, modelName, id, snapshot, requestType, query) {
let url = this.buildURL(modelName, id, snapshot, requestType, query);
let parsedUrl = new URL(url);
if (snapshot && snapshot.adapterOptions && snapshot.adapterOptions.sendEmailWhenPublished) {
parsedUrl.searchParams.append('send_email_when_published', 'true');
}
return parsedUrl.toString();
},
buildQuery(store, modelName, options) {
return options;
}
});