1
mirror of https://gitlab.com/commento/commento.git synced 2025-06-29 22:56:37 -04:00

api,frontend: add unsubscribe

This commit is contained in:
Adhityaa Chandrasekar
2019-02-18 16:30:54 -05:00
parent 60a9f2cc15
commit e1c94ecf15
11 changed files with 252 additions and 8 deletions

View File

@ -0,0 +1,54 @@
(function (global, document) {
"use strict";
(document);
var e;
// Update the email records.
global.emailUpdate = function() {
$(".err").text("");
$(".msg").text("");
e.sendModeratorNotifications = $("#moderator").is(":checked");
e.sendReplyNotifications = $("#reply").is(":checked");
var json = {
"email": e,
};
global.buttonDisable("#save-button");
global.post(global.origin + "/api/email/update", json, function(resp) {
global.buttonEnable("#save-button");
if (!resp.success) {
$(".err").text(resp.message);
return;
}
$(".msg").text("Successfully updated!");
});
}
// Checks the unsubscribeSecretHex token to retrieve current settings.
global.emailGet = function() {
$(".err").text("");
$(".msg").text("");
var json = {
"unsubscribeSecretHex": global.paramGet("unsubscribeSecretHex"),
};
global.post(global.origin + "/api/email/get", json, function(resp) {
$(".loading").hide();
if (!resp.success) {
$(".err").text(resp.message);
return;
}
e = resp.email;
$("#email").text(e.email);
$("#moderator").prop("checked", e.sendModeratorNotifications);
$("#reply").prop("checked", e.sendReplyNotifications);
$(".checkboxes").attr("style", "");
});
};
} (window.commento, document));