mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
9e7727752c
refs https://github.com/TryGhost/Team/issues/584 - No longer uses a API URL + redirect inside verification emails. This is replaced by a new route (`/settings/members/?verifyEmail=token`) that does the API request and shows a modal. - Removed update button when changing support email address in the Portal settings - Added `_meta` attribute to settings (uses same pattern as newsletters model) - When updating the `membersSupportAddress` setting (via the normal edit endpoint), the `sent_email_verification` meta property will get set by the API. When this new property is present, we'll show a warning that the support address requires verification.
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
import ApplicationSerializer from 'ghost-admin/serializers/application';
|
|
import {pluralize} from 'ember-inflector';
|
|
|
|
export default class Setting extends ApplicationSerializer {
|
|
serializeIntoHash(hash, type, record, options) {
|
|
// Settings API does not want ids
|
|
options = options || {};
|
|
options.includeId = false;
|
|
|
|
let root = pluralize(type.modelName);
|
|
let data = this.serialize(record, options);
|
|
let payload = [];
|
|
|
|
delete data.id;
|
|
delete data._meta;
|
|
|
|
Object.keys(data).forEach((k) => {
|
|
payload.push({key: k, value: data[k]});
|
|
});
|
|
|
|
hash[root] = payload;
|
|
}
|
|
|
|
normalizeArrayResponse(store, primaryModelClass, _payload, id, requestType) {
|
|
let payload = {settings: [this._extractObjectFromArrayPayload(_payload)]};
|
|
return super.normalizeArrayResponse(store, primaryModelClass, payload, id, requestType);
|
|
}
|
|
|
|
normalizeSingleResponse(store, primaryModelClass, _payload, id, requestType) {
|
|
let payload = {setting: this._extractObjectFromArrayPayload(_payload)};
|
|
return super.normalizeSingleResponse(store, primaryModelClass, payload, id, requestType);
|
|
}
|
|
|
|
_extractObjectFromArrayPayload(_payload) {
|
|
let payload = {id: '0'};
|
|
|
|
_payload.settings.forEach((setting) => {
|
|
payload[setting.key] = setting.value;
|
|
});
|
|
|
|
// HACK: Ember Data doesn't expose `meta` properties consistently
|
|
// - https://github.com/emberjs/data/issues/2905
|
|
//
|
|
// We need the `meta` data returned when saving so we extract it and dump
|
|
// it onto the model as an attribute then delete it again when serializing.
|
|
if (_payload.meta) {
|
|
payload._meta = _payload.meta;
|
|
}
|
|
|
|
return payload;
|
|
}
|
|
}
|