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); parsedUrl.searchParams.append('email_recipient_filter', emailRecipientFilter);
} }
if (snapshot?.adapterOptions?.newsletterId) { if (snapshot?.adapterOptions?.newsletter) {
const newsletterId = snapshot.adapterOptions.newsletterId; // TODO: rename newsletter_id to newsletter once changed in the backend
const newsletterId = snapshot.adapterOptions.newsletter;
parsedUrl.searchParams.append('newsletter_id', newsletterId); parsedUrl.searchParams.append('newsletter_id', newsletterId);
} }

View File

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

View File

@ -476,7 +476,7 @@ export default Component.extend({
try { try {
// will show alert for non-date related failed validations // 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(); this._cachePublishedAtBlogTZ();

View File

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

View File

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

View File

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