summaryrefslogtreecommitdiff
path: root/srv/src/http/tpl/unsubscribe.html
blob: ad01735cb1400208e9ac2ff147888278bdbef00c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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" . }}