liquid_feedback_frontend

changeset 1533:d432f85e868e

Completed firstlife group mirror feature
author bsw
date Mon Oct 05 15:51:47 2020 +0200 (2020-10-05)
parents 3c15fea3f1c0
children 0d9bb3937310
files app/main/_prefork/10_init.lua lib/firstlife/groups.lua
line diff
     1.1 --- a/app/main/_prefork/10_init.lua	Sun Oct 04 16:31:47 2020 +0200
     1.2 +++ b/app/main/_prefork/10_init.lua	Mon Oct 05 15:51:47 2020 +0200
     1.3 @@ -237,5 +237,21 @@
     1.4    max_fork = 1
     1.5  }
     1.6  
     1.7 +if config.firstlife_groups then
     1.8 +  assert(loadcached(encode.file_path(WEBMCP_BASE_PATH, "lib", "firstlife", "groups.lua")))()
     1.9 +  listen{
    1.10 +    {
    1.11 +      proto = "interval",
    1.12 +      name  = "send_pending_notifications",
    1.13 +      delay = 5,
    1.14 +      handler = function()
    1.15 +        firstlife_mirror_groups()
    1.16 +      end
    1.17 +    },
    1.18 +    min_fork = 1,
    1.19 +    max_fork = 1
    1.20 +  }
    1.21 +end
    1.22 +
    1.23  execute.inner()
    1.24  
     2.1 --- a/lib/firstlife/groups.lua	Sun Oct 04 16:31:47 2020 +0200
     2.2 +++ b/lib/firstlife/groups.lua	Mon Oct 05 15:51:47 2020 +0200
     2.3 @@ -17,13 +17,13 @@
     2.4    local new_user_hash = {}
     2.5  
     2.6    for i, user in ipairs(data) do
     2.7 -    print("  Processing user ID " .. user.id)
     2.8 +--    print("  Processing user ID " .. user.id)
     2.9      local user_id = tonumber(string.match(user.id, "^(.+)@"))
    2.10      new_user_hash[user_id] = user
    2.11      if old_privileges[user_id] then
    2.12 -      print("    Privilege entry exists")
    2.13 +--      print("    Privilege entry exists")
    2.14      else
    2.15 -      print("    Creating new privilege")
    2.16 +--      print("    Creating new privilege")
    2.17        local privilege = Privilege:new()
    2.18        privilege.unit_id = unit.id
    2.19        privilege.member_id = user_id
    2.20 @@ -36,7 +36,7 @@
    2.21  
    2.22    for i, old_privilege in ipairs(old_privileges_list) do
    2.23      if not new_user_hash[old_privilege.member_id] then
    2.24 -      print("  Destroying privilege for user ID " .. old_privilege.member_id)
    2.25 +--      print("  Destroying privilege for user ID " .. old_privilege.member_id)
    2.26        old_privilege:destroy()
    2.27      end
    2.28    end
    2.29 @@ -61,7 +61,7 @@
    2.30    local units_new = {}
    2.31  
    2.32    for i, feature in ipairs(data.things.features) do
    2.33 -    print(feature.id, feature.properties.name)
    2.34 +--    print(feature.id, feature.properties.name)
    2.35      units_new[feature.id] = feature
    2.36    end
    2.37  
    2.38 @@ -78,19 +78,19 @@
    2.39    for id, unit_new in pairs(units_new) do
    2.40      local name_new = unit_new.properties.name
    2.41      local unit
    2.42 -    print("Processing unit ID " .. id .. " with name " .. name_new)
    2.43 +--    print("Processing unit ID " .. id .. " with name " .. name_new)
    2.44      if old_units[id] then
    2.45        unit = old_units[id]
    2.46 -      print("  Unit already exists")
    2.47 +--      print("  Unit already exists")
    2.48        if old_units[id].name == name_new then
    2.49 -        print("  Name not changed")
    2.50 +--        print("  Name not changed")
    2.51        else
    2.52 -        print("  Name changed, updating")
    2.53 +--        print("  Name changed, updating")
    2.54          old_units[id].name = name_new
    2.55          old_units[id]:save()
    2.56        end
    2.57      else          
    2.58 -      print("  Creating as new unit")
    2.59 +--      print("  Creating as new unit")
    2.60        local u = Unit:new()
    2.61        u.name = name_new
    2.62        u.attr = json.object()
    2.63 @@ -112,4 +112,3 @@
    2.64  
    2.65  end
    2.66  
    2.67 -

Impressum / About Us