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