mirror of
https://github.com/plausible/analytics.git
synced 2024-12-26 02:55:02 +03:00
e67850c11d
* Make membership creation and role updates more explicit in terms of changesets * Extract invitation accept flow logic and refactor it slightly * Improve acceptation logic * Update moduledoc * Improve SiteLocker API and add typespecs * Stop naming function not returning a boolean like a predicate * Refactor rest of invitation actions and safeguard against rogue requests * Update code docs slightly * Extend `Billing.check_needs_update/1` tests * Parametrize selfhost flag and toggle SiteLocker logic on it * Add tests for newly extracted services * Add test case and a fix for locking site on grace period ended * Make invitation controller tests async as there's no more env patching * Add test cases for self-invites and fix one bug * Add and refactor tests for rejecting and removing invitations * Prevent issuing ownership transfer to existing owner * Improve name of the test * Improve `Billing.check_needs_to_upgrade/1` return value * Improve `Billing.SiteLocker.update_sites_for/1` and its tests * Fix typos Co-authored-by: hq1 <hq@mtod.org> * Make invitation removal and rejection resilient to races --------- Co-authored-by: hq1 <hq@mtod.org>
17 lines
445 B
Elixir
17 lines
445 B
Elixir
defmodule Plausible.Workers.LockSites do
|
|
use Plausible.Repo
|
|
use Oban.Worker, queue: :lock_sites
|
|
|
|
@impl Oban.Worker
|
|
def perform(_job) do
|
|
subscription_q = from(s in Plausible.Billing.Subscription, order_by: [desc: s.inserted_at])
|
|
users = Repo.all(from u in Plausible.Auth.User, preload: [subscription: ^subscription_q])
|
|
|
|
for user <- users do
|
|
Plausible.Billing.SiteLocker.update_sites_for(user)
|
|
end
|
|
|
|
:ok
|
|
end
|
|
end
|