annotate src/active.js.luan @ 89:3053a4fc10be

spy
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 13 Mar 2025 17:56:39 -0600
parents 624654817f99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
77
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
3 local Http = require "luan:http/Http.luan"
40
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local User = require "site:/lib/User.luan"
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local current_user = User.current or error()
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Notify = require "site:/lib/Notify.luan"
77
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
7 local remove_notify = Notify.remove or error()
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
8 local Chat = require "site:/lib/Chat.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
9 local get_chat_by_id = Chat.get_by_id or error()
40
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 return function()
89
Franklin Schmidt <fschmidt@gmail.com>
parents: 77
diff changeset
13 local spy = Http.request.cookies.spy ~= nil
Franklin Schmidt <fschmidt@gmail.com>
parents: 77
diff changeset
14 if spy then
Franklin Schmidt <fschmidt@gmail.com>
parents: 77
diff changeset
15 return
Franklin Schmidt <fschmidt@gmail.com>
parents: 77
diff changeset
16 end
40
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 local user = current_user() or error()
77
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
18 remove_notify(user)
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
19 local chat = Http.request.parameters.chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
20 if chat ~= nil then
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
21 chat = get_chat_by_id(chat) or error()
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
22 chat.read(user)
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
23 end
40
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 end