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

45 lines
974 B
Plaintext
Raw Normal View History

2018-06-15 11:03:24 -04:00
import { ajax } from "discourse/lib/ajax";
import AdminUser from "admin/models/admin-user";
const IncomingEmail = Discourse.Model.extend({});
IncomingEmail.reopenClass({
create(attrs) {
attrs = attrs || {};
if (attrs.user) {
attrs.user = AdminUser.create(attrs.user);
}
return this._super(attrs);
},
find(id) {
2016-06-30 13:55:44 -04: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";
filter = _.omit(filter, "status");
2018-06-15 11:03:24 -04:00
return ajax(`/admin/email/${status}.json?offset=${offset}`, {
data: filter
}).then(incomings =>
_.map(incomings, incoming => IncomingEmail.create(incoming))
);
},
loadRawEmail(id) {
2016-06-30 13:55:44 -04:00
return ajax(`/admin/email/incoming/${id}/raw.json`);
}
});
export default IncomingEmail;