mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 04:13:30 +03:00
c1d66f0b01
refs https://github.com/TryGhost/Ghost-Admin/pull/1796 We want to be able to display an email activity timeline in Ghost-Admin for each member. The quickest way to achieve that right now is to provide access to the `email_recipient` data for the member when fetching, this will allow clients to build up a timeline based on the event timestamps included with each email_recipient/email pair. - sets up `email_recipients` relationship in `Member` model - updates members API read endpoint to accept an `email_recipients` include parameter - appends `email_recipients.email` to the `withRelated` array when `email_recipients` is included so that we have data available for email subject and html/plaintext for previews - updates members API output serializer to include the email_recipients object in the output
32 lines
757 B
JavaScript
32 lines
757 B
JavaScript
const ghostBookshelf = require('./base');
|
|
|
|
const EmailRecipient = ghostBookshelf.Model.extend({
|
|
tableName: 'email_recipients',
|
|
hasTimestamps: false,
|
|
|
|
relationships: ['email'],
|
|
|
|
relationshipBelongsTo: {
|
|
email: 'emails'
|
|
},
|
|
|
|
email() {
|
|
return this.belongsTo('Email', 'email_id');
|
|
},
|
|
emailBatch() {
|
|
return this.belongsTo('EmailBatch', 'batch_id');
|
|
},
|
|
member() {
|
|
return this.belongsTo('Member', 'member_id');
|
|
}
|
|
});
|
|
|
|
const EmailRecipients = ghostBookshelf.Collection.extend({
|
|
model: EmailRecipient
|
|
});
|
|
|
|
module.exports = {
|
|
EmailRecipient: ghostBookshelf.model('EmailRecipient', EmailRecipient),
|
|
EmailRecipients: ghostBookshelf.collection('EmailRecipients', EmailRecipients)
|
|
};
|