annotate src/active.js.luan @ 77:624654817f99

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Mar 2025 19:29:41 -0600
parents 7ea33179592a
children 3053a4fc10be
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()
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 local user = current_user() or error()
77
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
14 remove_notify(user)
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
15 local chat = Http.request.parameters.chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
16 if chat ~= nil then
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
17 chat = get_chat_by_id(chat) or error()
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
18 chat.read(user)
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
19 end
40
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 end