2015-11-20 20:27:06 -05:00
|
|
|
import AdminUser from 'admin/models/admin-user';
|
2013-02-20 13:15:50 -05:00
|
|
|
|
2015-11-20 20:27:06 -05:00
|
|
|
const EmailLog = Discourse.Model.extend({});
|
2013-02-21 14:09:28 -05:00
|
|
|
|
2015-11-20 20:27:06 -05:00
|
|
|
EmailLog.reopenClass({
|
2014-02-14 18:50:08 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
create: function(attrs) {
|
2013-10-29 13:01:42 -04:00
|
|
|
attrs = attrs || {};
|
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
if (attrs.user) {
|
2015-11-20 20:27:06 -05:00
|
|
|
attrs.user = AdminUser.create(attrs.user);
|
2013-02-22 15:41:12 -05:00
|
|
|
}
|
2014-02-14 18:50:08 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
return this._super(attrs);
|
|
|
|
},
|
2013-02-21 14:09:28 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
findAll: function(filter) {
|
2014-02-14 18:50:08 -05:00
|
|
|
filter = filter || {};
|
2014-02-14 19:17:13 -05:00
|
|
|
var status = filter.status || "all";
|
2014-02-14 18:50:08 -05:00
|
|
|
filter = _.omit(filter, "status");
|
|
|
|
|
|
|
|
return Discourse.ajax("/admin/email/" + status + ".json", { data: filter }).then(function(logs) {
|
|
|
|
return _.map(logs, function (log) {
|
2015-11-20 20:27:06 -05:00
|
|
|
return EmailLog.create(log);
|
2013-04-03 16:06:55 -04:00
|
|
|
});
|
2013-02-22 15:41:12 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2013-02-21 14:09:28 -05:00
|
|
|
|
2015-11-20 20:27:06 -05:00
|
|
|
export default EmailLog;
|