2013-06-03 16:12:24 -04:00
|
|
|
/**
|
|
|
|
Our data model for showing a preview of an email
|
|
|
|
|
|
|
|
@class EmailPreview
|
|
|
|
@extends Discourse.Model
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
|
|
|
Discourse.EmailPreview = Discourse.Model.extend({});
|
|
|
|
|
|
|
|
Discourse.EmailPreview.reopenClass({
|
2015-10-30 14:05:54 -04:00
|
|
|
findDigest: function(lastSeenAt, username) {
|
2014-01-06 10:18:20 -05:00
|
|
|
|
|
|
|
if (Em.isEmpty(lastSeenAt)) {
|
2014-08-20 16:22:58 -04:00
|
|
|
lastSeenAt = moment().subtract(7, 'days').format('YYYY-MM-DD');
|
2014-01-06 10:18:20 -05:00
|
|
|
}
|
|
|
|
|
2015-10-30 14:05:54 -04:00
|
|
|
if (Em.isEmpty(username)) {
|
|
|
|
username = Discourse.User.current().username;
|
|
|
|
}
|
|
|
|
|
2013-11-30 21:30:41 -05:00
|
|
|
return Discourse.ajax("/admin/email/preview-digest.json", {
|
2015-10-30 14:05:54 -04:00
|
|
|
data: { last_seen_at: lastSeenAt, username: username }
|
2013-06-03 16:12:24 -04:00
|
|
|
}).then(function (result) {
|
|
|
|
return Discourse.EmailPreview.create(result);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|