mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 21:50:24 +08:00
faf2a8ada2
Followup to 64557c4076
42 lines
981 B
JavaScript
42 lines
981 B
JavaScript
import AdminUser from "admin/models/admin-user";
|
|
import EmberObject from "@ember/object";
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
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) {
|
|
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";
|
|
delete filter.status;
|
|
|
|
return ajax(`/admin/email/${status}.json?offset=${offset}`, {
|
|
data: filter,
|
|
}).then((incomings) =>
|
|
incomings.map((incoming) => IncomingEmail.create(incoming))
|
|
);
|
|
}
|
|
|
|
static loadRawEmail(id) {
|
|
return ajax(`/admin/email/incoming/${id}/raw.json`);
|
|
}
|
|
}
|