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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
793 B
Plaintext
Raw Normal View History

2016-06-30 13:55:44 -04:00
import { ajax } from "discourse/lib/ajax";
import AdminUser from "admin/models/admin-user";
2019-11-08 14:13:35 -05:00
import EmberObject from "@ember/object";
2019-11-08 14:13:35 -05:00
const EmailLog = EmberObject.extend({});
EmailLog.reopenClass({
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
if (attrs.post_url) {
attrs.post_url = Discourse.getURL(attrs.post_url);
}
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");
2016-06-30 13:55:44 -04:00
return ajax(`/admin/email/${status}.json?offset=${offset}`, {
data: filter
}).then(logs => logs.map(log => EmailLog.create(log)));
}
});
export default EmailLog;