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
This commit is contained in:
Simon Backx 2022-05-10 13:52:28 +02:00
parent a5fe1fa48c
commit 98e80cb6f8
6 changed files with 8 additions and 12 deletions

View File

@ -18,8 +18,9 @@ export default class Post extends ApplicationAdapter {
parsedUrl.searchParams.append('email_recipient_filter', emailRecipientFilter);
}
if (snapshot?.adapterOptions?.newsletterId) {
const newsletterId = snapshot.adapterOptions.newsletterId;
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);
}

View File

@ -274,7 +274,7 @@ export class PublishOptions {
const adapterOptions = {};
if (willEmail) {
adapterOptions.newsletterId = this.newsletter.id;
adapterOptions.newsletter = this.newsletter.id;
adapterOptions.emailRecipientFilter = this.recipientFilter;
}

View File

@ -476,7 +476,7 @@ export default Component.extend({
try {
// will show alert for non-date related failed validations
post = yield this.saveTask.perform({sendEmailWhenPublished, newsletterId: this.selectedNewsletter?.id, emailOnly});
post = yield this.saveTask.perform({sendEmailWhenPublished, newsletter: this.selectedNewsletter?.id, emailOnly});
this._cachePublishedAtBlogTZ();

View File

@ -110,10 +110,8 @@ export default class ModalPostPreviewEmailComponent extends Component {
let {post} = this.args;
// Fetch newsletter
if (!this.newsletter && post.newsletterId) {
const newsletters = (await this.store.query('newsletter', {filter: 'status:active+id:' + post.newsletterId, limit: 1})).toArray();
const defaultNewsletter = newsletters[0];
this.newsletter = defaultNewsletter;
if (!this.newsletter && post.newsletter) {
this.newsletter = post.newsletter;
}
if (!this.newsletter) {

View File

@ -492,7 +492,7 @@ export default class EditorController extends Controller {
if (options.sendEmailWhenPublished && (isPublishing || isScheduling)) {
options.adapterOptions = Object.assign({}, options.adapterOptions, {
sendEmailWhenPublished: options.sendEmailWhenPublished,
newsletterId: options.newsletterId
newsletter: options.newsletter
});
}
}

View File

@ -111,9 +111,6 @@ export default Model.extend(Comparable, ValidationEngine, {
featureImageAlt: attr('string'),
featureImageCaption: attr('string'),
// TODO: delete when newsletter relationship/embed is fully defined
newsletterId: attr(),
authors: hasMany('user', {embedded: 'always', async: false}),
createdBy: belongsTo('user', {async: true}),
email: belongsTo('email', {async: false}),