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

35 lines
759 B
Plaintext
Raw Normal View History

2018-06-15 23:03:24 +08:00
import { ajax } from "discourse/lib/ajax";
import AdminUser from "admin/models/admin-user";
const EmailLog = Discourse.Model.extend({});
EmailLog.reopenClass({
create(attrs) {
2013-10-30 01:01:42 +08:00
attrs = attrs || {};
if (attrs.user) {
attrs.user = AdminUser.create(attrs.user);
}
2014-02-15 07:50:08 +08:00
if (attrs.post_url) {
attrs.post_url = Discourse.getURL(attrs.post_url);
}
return this._super(attrs);
},
findAll(filter, offset) {
2014-02-15 07:50:08 +08:00
filter = filter || {};
offset = offset || 0;
const status = filter.status || "sent";
2014-02-15 07:50:08 +08:00
filter = _.omit(filter, "status");
2018-06-15 23:03:24 +08:00
return ajax(`/admin/email/${status}.json?offset=${offset}`, {
data: filter
}).then(logs => _.map(logs, log => EmailLog.create(log)));
}
});
export default EmailLog;