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

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

33 lines
799 B
JavaScript
Raw Normal View History

import AdminUser from "admin/models/admin-user";
2019-11-09 03:13:35 +08:00
import EmberObject from "@ember/object";
2016-07-01 01:55:44 +08:00
import { ajax } from "discourse/lib/ajax";
import getURL from "discourse-common/lib/get-url";
export default class EmailLog extends EmberObject {
static 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 = getURL(attrs.post_url);
}
return super.create(attrs);
}
static findAll(filter, offset) {
2014-02-15 07:50:08 +08:00
filter = filter || {};
offset = offset || 0;
const status = filter.status || "sent";
2020-09-02 01:38:57 +08:00
delete filter.status;
2014-02-15 07:50:08 +08:00
2016-07-01 01:55:44 +08:00
return ajax(`/admin/email/${status}.json?offset=${offset}`, {
data: filter,
}).then((logs) => logs.map((log) => EmailLog.create(log)));
}
}