liquid_feedback_frontend

diff model/event.lua @ 1158:e9f6ae14bc72

Updated event notifications and moved code from config to prefork initializer
author bsw
date Tue Mar 24 11:50:08 2015 +0100 (2015-03-24)
parents c037558f6610
children dafce7add549
line diff
     1.1 --- a/model/event.lua	Mon Mar 23 23:18:43 2015 +0100
     1.2 +++ b/model/event.lua	Tue Mar 24 11:50:08 2015 +0100
     1.3 @@ -59,8 +59,7 @@
     1.4      :add_where("event_seen_by_member.member_id ISNULL OR event_seen_by_member.member_id != member.id")
     1.5      :exec()
     1.6      
     1.7 -  print (_("Event #{id} -> #{num} members", { id = self.id, num = #members_to_notify }))
     1.8 -
     1.9 +  io.stderr:write("Sending notifications for event #{id} to #{num} members", { id = self.id, num = #members_to_notify })
    1.10  
    1.11    local url
    1.12  
    1.13 @@ -167,19 +166,31 @@
    1.14      
    1.15      event:send_notification()
    1.16      
    1.17 +    if config.notification_handler_func then
    1.18 +      config.notification_handler_func(event)
    1.19 +    end
    1.20 +    
    1.21      return true
    1.22  
    1.23    end
    1.24  
    1.25  end
    1.26  
    1.27 +function Event:send_pending_notifications()
    1.28 +  while true do
    1.29 +    if not Event:send_next_notification() then
    1.30 +      break 
    1.31 +    end
    1.32 +  end
    1.33 +end
    1.34 +
    1.35  function Event:send_notifications_loop()
    1.36  
    1.37    while true do
    1.38      local did_work = Event:send_next_notification()
    1.39      if not did_work then
    1.40 -      print "Sleeping 1 second"
    1.41 -      os.execute("sleep 1")
    1.42 +      print "Sleeping 5 second"
    1.43 +      os.execute("sleep 5")
    1.44      end
    1.45    end
    1.46    

Impressum / About Us