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

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

38 lines
891 B
JavaScript
Raw Normal View History

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";
import AdminUser from "admin/models/admin-user";
export default class IncomingEmail extends EmberObject {
static create(attrs) {
attrs = attrs || {};
if (attrs.user) {
attrs.user = AdminUser.create(attrs.user);
}
return super.create(attrs);
}
static find(id) {
2016-06-30 13:55:44 -04:00
return ajax(`/admin/email/incoming/${id}.json`);
}
static findByBounced(id) {
return ajax(`/admin/email/incoming_from_bounced/${id}.json`);
}
static findAll(filter, offset) {
filter = filter || {};
offset = offset || 0;
const status = filter.status || "received";
2020-09-01 13:38:57 -04:00
delete filter.status;
2016-06-30 13:55:44 -04:00
return ajax(`/admin/email/${status}.json?offset=${offset}`, {
data: filter,
}).then((incomings) =>
incomings.map((incoming) => IncomingEmail.create(incoming))
);
}
}