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

26 lines
673 B
Plaintext
Raw Normal View History

2018-06-15 11:03:24 -04:00
import { ajax } from "discourse/lib/ajax";
const EmailPreview = Discourse.Model.extend({});
export function oneWeekAgo() {
2018-06-15 11:03:24 -04:00
return moment()
.locale("en")
.subtract(7, "days")
.format("YYYY-MM-DD");
}
EmailPreview.reopenClass({
findDigest(username, lastSeenAt) {
2016-06-30 13:55:44 -04:00
return ajax("/admin/email/preview-digest.json", {
data: { last_seen_at: lastSeenAt || oneWeekAgo(), username }
}).then(result => EmailPreview.create(result));
},
sendDigest(username, lastSeenAt, email) {
return ajax("/admin/email/send-digest.json", {
data: { last_seen_at: lastSeenAt || oneWeekAgo(), username, email }
});
2018-06-15 11:03:24 -04:00
}
});
export default EmailPreview;