summaryrefslogtreecommitdiff
path: root/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'static/src')
-rw-r--r--static/src/mailinglist/finalize.md53
-rw-r--r--static/src/mailinglist/unsubscribe.md54
2 files changed, 107 insertions, 0 deletions
diff --git a/static/src/mailinglist/finalize.md b/static/src/mailinglist/finalize.md
new file mode 100644
index 0000000..fe8f741
--- /dev/null
+++ b/static/src/mailinglist/finalize.md
@@ -0,0 +1,53 @@
+---
+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 subToken = urlParams.get('subToken');
+
+ if (!subToken) {
+ setErr("No subscription token provided");
+ return;
+ }
+
+ const finalizeForm = new FormData();
+ finalizeForm.append('subToken', subToken);
+
+ const finalizeReq = new Request('/api/mailinglist/finalize', {
+ method: 'POST',
+ body: finalizeForm,
+ });
+
+ const res = await fetch(finalizeReq)
+ .then(response => response.json());
+
+ if (res.error) {
+ setErr(res.error);
+ return;
+ }
+
+ resultSpan.className = "success";
+ resultSpan.innerHTML = "Your email subscription has been finalized! Please go on about your day.";
+
+})();
+
+</script>
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>
+