discourse/app/assets/javascripts/admin/models/email-log.js.es6
2018-06-15 17:03:24 +02:00

31 lines
669 B
JavaScript

import { ajax } from "discourse/lib/ajax";
import AdminUser from "admin/models/admin-user";
const EmailLog = Discourse.Model.extend({});
EmailLog.reopenClass({
create(attrs) {
attrs = attrs || {};
if (attrs.user) {
attrs.user = AdminUser.create(attrs.user);
}
return this._super(attrs);
},
findAll(filter, offset) {
filter = filter || {};
offset = offset || 0;
const status = filter.status || "sent";
filter = _.omit(filter, "status");
return ajax(`/admin/email/${status}.json?offset=${offset}`, {
data: filter
}).then(logs => _.map(logs, log => EmailLog.create(log)));
}
});
export default EmailLog;