2022-04-04 21:26:49 +03:00
|
|
|
import Model, {attr} from '@ember-data/model';
|
|
|
|
import ValidationEngine from '../mixins/validation-engine';
|
|
|
|
|
|
|
|
export default class Newsletter extends Model.extend(ValidationEngine) {
|
|
|
|
validationType = 'newsletter';
|
|
|
|
|
|
|
|
@attr name;
|
2022-04-07 15:49:54 +03:00
|
|
|
@attr slug;
|
2022-04-04 21:26:49 +03:00
|
|
|
@attr description;
|
|
|
|
|
|
|
|
@attr senderName;
|
|
|
|
@attr senderEmail;
|
2022-04-12 16:01:27 +03:00
|
|
|
@attr({defaultValue: 'newsletter'}) senderReplyTo;
|
2022-04-04 21:26:49 +03:00
|
|
|
|
|
|
|
@attr({defaultValue: 'active'}) status;
|
2022-04-19 14:31:16 +03:00
|
|
|
@attr({defaultValue: true}) subscribeOnSignup;
|
2022-04-14 17:40:04 +03:00
|
|
|
@attr({defaultValue: 'members'}) visibility;
|
2022-04-04 21:26:49 +03:00
|
|
|
@attr({defaultValue: 0}) sortOrder;
|
2022-10-13 09:24:46 +03:00
|
|
|
@attr({defaultValue: true}) feedbackEnabled;
|
2022-04-04 21:26:49 +03:00
|
|
|
|
2022-04-14 13:01:09 +03:00
|
|
|
// Design-related properties
|
2022-04-04 21:26:49 +03:00
|
|
|
@attr headerImage;
|
|
|
|
@attr({defaultValue: true}) showHeaderIcon;
|
|
|
|
@attr({defaultValue: true}) showHeaderTitle;
|
2022-04-20 18:04:58 +03:00
|
|
|
@attr({defaultValue: true}) showHeaderName;
|
2023-03-14 13:29:43 +03:00
|
|
|
@attr({defaultValue: true}) showPostTitleSection;
|
2024-06-05 19:59:30 +03:00
|
|
|
@attr({defaultValue: false}) showExcerpt;
|
2023-03-14 18:35:23 +03:00
|
|
|
@attr({defaultValue: true}) showCommentCta;
|
2023-03-15 16:44:37 +03:00
|
|
|
@attr({defaultValue: false}) showSubscriptionDetails;
|
2023-03-20 13:26:19 +03:00
|
|
|
@attr({defaultValue: false}) showLatestPosts;
|
2022-04-04 21:26:49 +03:00
|
|
|
@attr({defaultValue: 'sans_serif'}) titleFontCategory;
|
|
|
|
@attr({defaultValue: 'center'}) titleAlignment;
|
|
|
|
@attr({defaultValue: true}) showFeatureImage;
|
|
|
|
@attr({defaultValue: 'sans_serif'}) bodyFontCategory;
|
2023-03-28 15:23:08 +03:00
|
|
|
@attr({defaultValue: 'light'}) backgroundColor;
|
|
|
|
@attr({defaultValue: null}) borderColor;
|
|
|
|
@attr({defaultValue: null}) titleColor;
|
2022-04-14 13:01:09 +03:00
|
|
|
@attr footerContent;
|
2022-04-04 21:26:49 +03:00
|
|
|
@attr({defaultValue: true}) showBadge;
|
2022-04-26 10:48:17 +03:00
|
|
|
@attr count;
|
2022-04-13 21:34:48 +03:00
|
|
|
|
|
|
|
// HACK - not a real model attribute but a workaround for Ember Data not
|
|
|
|
// exposing meta from save responses
|
|
|
|
@attr _meta;
|
2022-05-05 15:33:26 +03:00
|
|
|
|
|
|
|
/**
|
2023-07-24 12:47:57 +03:00
|
|
|
* The filter that we should use to filter out members that are actively subscribed to this newsletter
|
2022-05-05 15:33:26 +03:00
|
|
|
*/
|
|
|
|
get recipientFilter() {
|
2023-07-24 12:47:57 +03:00
|
|
|
const filter = [`newsletters.slug:${this.slug}`, 'email_disabled:0'];
|
2022-05-05 15:33:26 +03:00
|
|
|
if (this.visibility === 'paid') {
|
2023-07-24 12:47:57 +03:00
|
|
|
filter.push('status:-free');
|
2022-05-05 15:33:26 +03:00
|
|
|
}
|
2023-07-24 12:47:57 +03:00
|
|
|
return filter.join('+');
|
2022-05-05 15:33:26 +03:00
|
|
|
}
|
2022-04-04 21:26:49 +03:00
|
|
|
}
|