summaryrefslogtreecommitdiff
path: root/srv/src/http/tpl
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-21 14:03:38 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-21 14:03:38 -0600
commit4dc1683d3ec01eb5030fadab182631e7bbe448c0 (patch)
tree245497641e867858a3e85220e10624a85341f540 /srv/src/http/tpl
parent7335295dc0e6470abdbc6860ac567db76f4859fc (diff)
Serve mailing list finalize and unsubscribe endpoints
Diffstat (limited to 'srv/src/http/tpl')
-rw-r--r--srv/src/http/tpl/finalize.html45
-rw-r--r--srv/src/http/tpl/unsubscribe.html44
2 files changed, 89 insertions, 0 deletions
diff --git a/srv/src/http/tpl/finalize.html b/srv/src/http/tpl/finalize.html
new file mode 100644
index 0000000..8bdfceb
--- /dev/null
+++ b/srv/src/http/tpl/finalize.html
@@ -0,0 +1,45 @@
+{{ define "body" }}
+
+<script async type="module" src="{{ StaticURL "api.js" }}"></script>
+
+<style>
+#result.success { color: green; }
+#result.fail { color: red; }
+</style>
+
+<span id="result"></span>
+
+<script>
+
+(async () => {
+
+ const resultSpan = document.getElementById("result");
+
+ try {
+
+ const urlParams = new URLSearchParams(window.location.search);
+ const subToken = urlParams.get('subToken');
+
+ if (!subToken) throw "No subscription token provided";
+
+ const api = await import("{{ StaticURL "api.js" }}");
+
+ await api.call('/api/mailinglist/finalize', {
+ body: { subToken },
+ });
+
+ resultSpan.className = "success";
+ resultSpan.innerHTML = "Your email subscription has been finalized! Please go on about your day.";
+
+ } catch (e) {
+ resultSpan.className = "fail";
+ resultSpan.innerHTML = e;
+ }
+
+})();
+
+</script>
+
+{{ end }}
+
+{{ template "base.html" . }}
diff --git a/srv/src/http/tpl/unsubscribe.html b/srv/src/http/tpl/unsubscribe.html
new file mode 100644
index 0000000..ad01735
--- /dev/null
+++ b/srv/src/http/tpl/unsubscribe.html
@@ -0,0 +1,44 @@
+{{ define "body" }}
+
+<script async type="module" src="{{ StaticURL "api.js" }}"></script>
+
+<style>
+#result.success { color: green; }
+#result.fail { color: red; }
+</style>
+
+<span id="result"></span>
+
+<script>
+
+(async () => {
+
+ const resultSpan = document.getElementById("result");
+
+ try {
+ const urlParams = new URLSearchParams(window.location.search);
+ const unsubToken = urlParams.get('unsubToken');
+
+ if (!unsubToken) throw "No unsubscribe token provided";
+
+ const api = await import("{{ StaticURL "api.js" }}");
+
+ await api.call('/api/mailinglist/unsubscribe', {
+ body: { unsubToken },
+ });
+
+ resultSpan.className = "success";
+ resultSpan.innerHTML = "You have been unsubscribed! Please go on about your day.";
+
+ } catch (e) {
+ resultSpan.className = "fail";
+ resultSpan.innerHTML = e;
+ }
+
+})();
+
+</script>
+
+{{ end }}
+
+{{ template "base.html" . }}