# HG changeset patch # User bsw # Date 1601905907 -7200 # Node ID d432f85e868e70685754c4fb45b1c00f2f4fac1d # Parent 3c15fea3f1c0614371450b08904356d6349b4ce5 Completed firstlife group mirror feature diff -r 3c15fea3f1c0 -r d432f85e868e app/main/_prefork/10_init.lua --- a/app/main/_prefork/10_init.lua Sun Oct 04 16:31:47 2020 +0200 +++ b/app/main/_prefork/10_init.lua Mon Oct 05 15:51:47 2020 +0200 @@ -237,5 +237,21 @@ max_fork = 1 } +if config.firstlife_groups then + assert(loadcached(encode.file_path(WEBMCP_BASE_PATH, "lib", "firstlife", "groups.lua")))() + listen{ + { + proto = "interval", + name = "send_pending_notifications", + delay = 5, + handler = function() + firstlife_mirror_groups() + end + }, + min_fork = 1, + max_fork = 1 + } +end + execute.inner() diff -r 3c15fea3f1c0 -r d432f85e868e lib/firstlife/groups.lua --- a/lib/firstlife/groups.lua Sun Oct 04 16:31:47 2020 +0200 +++ b/lib/firstlife/groups.lua Mon Oct 05 15:51:47 2020 +0200 @@ -17,13 +17,13 @@ local new_user_hash = {} for i, user in ipairs(data) do - print(" Processing user ID " .. user.id) +-- print(" Processing user ID " .. user.id) local user_id = tonumber(string.match(user.id, "^(.+)@")) new_user_hash[user_id] = user if old_privileges[user_id] then - print(" Privilege entry exists") +-- print(" Privilege entry exists") else - print(" Creating new privilege") +-- print(" Creating new privilege") local privilege = Privilege:new() privilege.unit_id = unit.id privilege.member_id = user_id @@ -36,7 +36,7 @@ for i, old_privilege in ipairs(old_privileges_list) do if not new_user_hash[old_privilege.member_id] then - print(" Destroying privilege for user ID " .. old_privilege.member_id) +-- print(" Destroying privilege for user ID " .. old_privilege.member_id) old_privilege:destroy() end end @@ -61,7 +61,7 @@ local units_new = {} for i, feature in ipairs(data.things.features) do - print(feature.id, feature.properties.name) +-- print(feature.id, feature.properties.name) units_new[feature.id] = feature end @@ -78,19 +78,19 @@ for id, unit_new in pairs(units_new) do local name_new = unit_new.properties.name local unit - print("Processing unit ID " .. id .. " with name " .. name_new) +-- print("Processing unit ID " .. id .. " with name " .. name_new) if old_units[id] then unit = old_units[id] - print(" Unit already exists") +-- print(" Unit already exists") if old_units[id].name == name_new then - print(" Name not changed") +-- print(" Name not changed") else - print(" Name changed, updating") +-- print(" Name changed, updating") old_units[id].name = name_new old_units[id]:save() end else - print(" Creating as new unit") +-- print(" Creating as new unit") local u = Unit:new() u.name = name_new u.attr = json.object() @@ -112,4 +112,3 @@ end -