Ghost/ghost/admin/app/serializers/member.js
Kevin Ansfield eca8392296 🐛 Fixed potential "Request entity too large" error when saving members
no issue

- `email_recipient` records are embedded alongside member data when fetching individual members so the member activity feed can be generated
- full email details are included for each email so that previews can be generated which can result in a large payload
- by default Ember Data will push all embedded records back to the server when saving which resulted in `Request entity too large` errors in some environments when a member has received many emails
2020-12-16 13:41:45 +00:00

27 lines
773 B
JavaScript

/* eslint-disable camelcase */
import ApplicationSerializer from './application';
import {EmbeddedRecordsMixin} from '@ember-data/serializer/rest';
export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
attrs: {
createdAtUTC: {key: 'created_at'},
labels: {embedded: 'always'},
emailRecipients: {embedded: 'always'}
},
serialize(/*snapshot, options*/) {
let json = this._super(...arguments);
// Properties that exist on the model but we don't want sent in the payload
delete json.stripe;
delete json.geolocation;
delete json.email_recipients;
// Normalize properties
json.name = json.name || '';
json.note = json.note || '';
return json;
}
});