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.

46 lines
1001 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";
2019-11-09 03:13:35 +08:00
const IncomingEmail = EmberObject.extend({});
IncomingEmail.reopenClass({
create(attrs) {
attrs = attrs || {};
if (attrs.user) {
attrs.user = AdminUser.create(attrs.user);
}
return this._super(attrs);
},
find(id) {
2016-07-01 01:55:44 +08:00
return ajax(`/admin/email/incoming/${id}.json`);
},
findByBounced(id) {
return ajax(`/admin/email/incoming_from_bounced/${id}.json`);
},
findAll(filter, offset) {
filter = filter || {};
offset = offset || 0;
const status = filter.status || "received";
2020-09-02 01:38:57 +08:00
delete filter.status;
2016-07-01 01:55:44 +08:00
return ajax(`/admin/email/${status}.json?offset=${offset}`, {
data: filter,
}).then((incomings) =>
incomings.map((incoming) => IncomingEmail.create(incoming))
);
},
loadRawEmail(id) {
2016-07-01 01:55:44 +08:00
return ajax(`/admin/email/incoming/${id}/raw.json`);
},
});
export default IncomingEmail;