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
|
|
|
|
2023-03-17 06:18:42 -04: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", {
|
2017-06-28 15:36:34 -04:00
|
|
|
data: { last_seen_at: lastSeenAt || oneWeekAgo(), username },
|
|
|
|
}).then((result) => EmailPreview.create(result));
|
2023-03-17 06:18:42 -04:00
|
|
|
}
|
2016-11-23 17:46:57 -05:00
|
|
|
|
2023-03-17 06:18:42 -04:00
|
|
|
static sendDigest(username, lastSeenAt, email) {
|
2016-11-23 17:46:57 -05:00
|
|
|
return ajax("/admin/email/send-digest.json", {
|
2023-01-04 17:57:12 -05:00
|
|
|
type: "POST",
|
2017-06-28 15:36:34 -04:00
|
|
|
data: { last_seen_at: lastSeenAt || oneWeekAgo(), username, email },
|
2016-11-23 17:46:57 -05:00
|
|
|
});
|
2023-03-17 06:18:42 -04:00
|
|
|
}
|
|
|
|
}
|
2015-11-20 20:27:06 -05:00
|
|
|
|
2023-03-17 06:18:42 -04:00
|
|
|
export function oneWeekAgo() {
|
|
|
|
return moment().locale("en").subtract(7, "days").format("YYYY-MM-DD");
|
|
|
|
}
|