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

Failed to ignore revisions in .git-blame-ignore-revs.

28 lines
711 B
JavaScript
Raw Normal View History

2018-06-15 23:03:24 +08:00
import { ajax } from "discourse/lib/ajax";
2019-11-09 03:13:35 +08:00
import EmberObject from "@ember/object";
const EmailPreview = EmberObject.extend({});
export function oneWeekAgo() {
2018-06-15 23:03:24 +08:00
return moment()
.locale("en")
.subtract(7, "days")
.format("YYYY-MM-DD");
}
EmailPreview.reopenClass({
findDigest(username, lastSeenAt) {
2016-07-01 01:55:44 +08: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 23:03:24 +08:00
}
});
export default EmailPreview;