summaryrefslogtreecommitdiff
path: root/static/src/mailinglist/unsubscribe.md
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2021-08-03 16:28:22 -0600
committerBrian Picciano <mediocregopher@gmail.com>2021-08-03 16:28:22 -0600
commit9c3ea8dd803d6f0df768e3ae37f8c4ab2efbcc5c (patch)
tree93f2f3e104a255e4959816ac762b70e7dafd6562 /static/src/mailinglist/unsubscribe.md
parentec4aac24abc35fcf192c13a3fc9b2b65875c3444 (diff)
implement finalize and unsubscribe endpoints
Diffstat (limited to 'static/src/mailinglist/unsubscribe.md')
-rw-r--r--static/src/mailinglist/unsubscribe.md54
1 files changed, 54 insertions, 0 deletions
diff --git a/static/src/mailinglist/unsubscribe.md b/static/src/mailinglist/unsubscribe.md
new file mode 100644
index 0000000..6a118a0
--- /dev/null
+++ b/static/src/mailinglist/unsubscribe.md
@@ -0,0 +1,54 @@
+---
+layout: page
+title: ""
+nofollow: true
+---
+
+<style>
+#result.success { color: green; }
+#result.fail { color: red; }
+</style>
+
+<span id="result"></span>
+
+<script>
+
+(async () => {
+ const resultSpan = document.getElementById("result");
+
+ function setErr(errStr) {
+ resultSpan.className = "fail";
+ resultSpan.innerHTML = errStr;
+ }
+
+ const urlParams = new URLSearchParams(window.location.search);
+ const unsubToken = urlParams.get('unsubToken');
+
+ if (!unsubToken) {
+ setErr("No unsubscribe token provided");
+ return;
+ }
+
+ const unsubscribeForm = new FormData();
+ unsubscribeForm.append('unsubToken', unsubToken);
+
+ const unsubscribeReq = new Request('/api/mailinglist/unsubscribe', {
+ method: 'POST',
+ body: unsubscribeForm,
+ });
+
+ const res = await fetch(unsubscribeReq)
+ .then(response => response.json());
+
+ if (res.error) {
+ setErr(res.error);
+ return;
+ }
+
+ resultSpan.className = "success";
+ resultSpan.innerHTML = "You have been unsubscribed! Please go on about your day.";
+
+})();
+
+</script>
+