discourse/app/assets/javascripts/admin/models/email-log.js.es6

30 lines
648 B
Text
Raw Normal View History

import AdminUser from 'admin/models/admin-user';
const EmailLog = Discourse.Model.extend({});
EmailLog.reopenClass({
2014-02-14 18:50:08 -05:00
create(attrs) {
2013-10-29 13:01:42 -04:00
attrs = attrs || {};
if (attrs.user) {
attrs.user = AdminUser.create(attrs.user);
}
2014-02-14 18:50:08 -05:00
return this._super(attrs);
},
findAll(filter, offset) {
2014-02-14 18:50:08 -05:00
filter = filter || {};
offset = offset || 0;
const status = filter.status || "sent";
2014-02-14 18:50:08 -05:00
filter = _.omit(filter, "status");
return Discourse.ajax(`/admin/email/${status}.json?offset=${offset}`, { data: filter })
.then(logs => _.map(logs, log => EmailLog.create(log)));
}
});
export default EmailLog;