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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
684 B
JavaScript
Raw Normal View History

2019-11-08 14:13:35 -05:00
import EmberObject from "@ember/object";
2016-06-30 13:55:44 -04:00
import { ajax } from "discourse/lib/ajax";
2019-11-08 14:13:35 -05:00
export default class EmailPreview extends EmberObject {
static 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));
}
static sendDigest(username, lastSeenAt, email) {
return ajax("/admin/email/send-digest.json", {
type: "POST",
data: { last_seen_at: lastSeenAt || oneWeekAgo(), username, email },
});
}
}
export function oneWeekAgo() {
return moment().locale("en").subtract(7, "days").format("YYYY-MM-DD");
}