2016-07-01 01:55:44 +08:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2015-11-21 09:27:06 +08:00
|
|
|
import AdminUser from "admin/models/admin-user";
|
2019-11-09 03:13:35 +08:00
|
|
|
import EmberObject from "@ember/object";
|
2013-02-21 02:15:50 +08:00
|
|
|
|
2019-11-09 03:13:35 +08:00
|
|
|
const EmailLog = EmberObject.extend({});
|
2013-02-22 03:09:28 +08:00
|
|
|
|
2015-11-21 09:27:06 +08:00
|
|
|
EmailLog.reopenClass({
|
2016-01-19 07:57:55 +08:00
|
|
|
create(attrs) {
|
2013-10-30 01:01:42 +08:00
|
|
|
attrs = attrs || {};
|
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
if (attrs.user) {
|
2015-11-21 09:27:06 +08:00
|
|
|
attrs.user = AdminUser.create(attrs.user);
|
2013-02-23 04:41:12 +08:00
|
|
|
}
|
2014-02-15 07:50:08 +08:00
|
|
|
|
2018-08-09 04:47:54 +08:00
|
|
|
if (attrs.post_url) {
|
|
|
|
attrs.post_url = Discourse.getURL(attrs.post_url);
|
|
|
|
}
|
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
return this._super(attrs);
|
|
|
|
},
|
2013-02-22 03:09:28 +08:00
|
|
|
|
2016-01-19 07:57:55 +08:00
|
|
|
findAll(filter, offset) {
|
2014-02-15 07:50:08 +08:00
|
|
|
filter = filter || {};
|
2016-01-19 07:57:55 +08:00
|
|
|
offset = offset || 0;
|
|
|
|
|
|
|
|
const status = filter.status || "sent";
|
2014-02-15 07:50:08 +08:00
|
|
|
filter = _.omit(filter, "status");
|
|
|
|
|
2016-07-01 01:55:44 +08:00
|
|
|
return ajax(`/admin/email/${status}.json?offset=${offset}`, {
|
|
|
|
data: filter
|
2018-11-19 17:46:46 +08:00
|
|
|
}).then(logs => logs.map(log => EmailLog.create(log)));
|
2013-02-23 04:41:12 +08:00
|
|
|
}
|
|
|
|
});
|
2013-02-22 03:09:28 +08:00
|
|
|
|
2015-11-21 09:27:06 +08:00
|
|
|
export default EmailLog;
|