Mercurial Hosting > chat
comparison src/lib/Notify.luan @ 41:818697418dbe
add voice link
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 27 Feb 2025 19:05:57 -0700 |
parents | 7ea33179592a |
children | e138343b2c76 |
comparison
equal
deleted
inserted
replaced
40:7ea33179592a | 41:818697418dbe |
---|---|
42 local now = time_now() | 42 local now = time_now() |
43 for _, user_id in ipairs(user_ids) do | 43 for _, user_id in ipairs(user_ids) do |
44 local user = get_user_by_id(user_id) | 44 local user = get_user_by_id(user_id) |
45 if users[user_id] == nil and user.notify_email ~= nil and (user.multi_notify or not user.was_notified) then | 45 if users[user_id] == nil and user.notify_email ~= nil and (user.multi_notify or not user.was_notified) then |
46 users[user_id] = now | 46 users[user_id] = now |
47 logger.info("add "..user_id) | 47 -- logger.info("add "..user_id) |
48 end | 48 end |
49 end | 49 end |
50 end | 50 end |
51 | 51 |
52 function fns.remove(user_id) | 52 function fns.remove(user_id) |
53 users[user_id] = nil | 53 users[user_id] = nil |
54 logger.info("remove "..user_id) | 54 -- logger.info("remove "..user_id) |
55 end | 55 end |
56 | 56 |
57 function fns.notify() | 57 function fns.notify() |
58 logger.info("notify") | 58 -- logger.info("notify") |
59 local now = time_now() | 59 local now = time_now() |
60 for user_id, when in pairs(shallow_copy(users)) do | 60 for user_id, when in pairs(shallow_copy(users)) do |
61 if now - when > wait then | 61 if now - when > wait then |
62 local user = get_user_by_id(user_id) | 62 local user = get_user_by_id(user_id) |
63 logger.info("notify "..user.notify_email.." "..user_id) | 63 -- logger.info("notify "..user.notify_email.." "..user_id) |
64 send_mail { | 64 send_mail { |
65 From = "Web Chat <chat@luan.software>" | 65 From = "Web Chat <chat@luan.software>" |
66 To = user.notify_email | 66 To = user.notify_email |
67 Subject = "New Messages" | 67 Subject = "New Messages" |
68 body = `%> | 68 body = `%> |