Skip to content

Commit

Permalink
rm zombie code from brig.
Browse files Browse the repository at this point in the history
  • Loading branch information
fisx committed Nov 6, 2024
1 parent 6ef5df7 commit bd445d0
Showing 1 changed file with 3 additions and 41 deletions.
44 changes: 3 additions & 41 deletions services/brig/src/Brig/Team/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import Wire.InvitationStore (InvitationStore (..), PaginatedResult (..), StoredI
import Wire.InvitationStore qualified as Store
import Wire.Sem.Concurrency
import Wire.TeamInvitationSubsystem
import Wire.TeamInvitationSubsystem.Interpreter (toInvitation)
import Wire.UserKeyStore
import Wire.UserSubsystem
import Wire.UserSubsystem.Error
Expand Down Expand Up @@ -236,38 +237,12 @@ listInvitations uid tid startingId mSize = do
-- To create the correct team invitation URL, we need to detect whether the invited account already exists.
-- Optimization: if url is not to be shown, do not check for existing personal user.
toInvitationHack :: ShowOrHideInvitationUrl -> StoredInvitation -> Sem r Invitation
toInvitationHack HideInvitationUrl si = toInvitation False HideInvitationUrl si -- isPersonalUserMigration is always ignored here
toInvitationHack HideInvitationUrl si =
toInvitation False HideInvitationUrl si -- isPersonalUserMigration is always ignored here
toInvitationHack ShowInvitationUrl si = do
isPersonalUserMigration <- isPersonalUser (mkEmailKey si.email)
toInvitation isPersonalUserMigration ShowInvitationUrl si

-- | brig used to not store the role, so for migration we allow this to be empty and fill in the
-- default here.
toInvitation ::
( Member TinyLog r,
Member (Input TeamTemplates) r
) =>
Bool ->
ShowOrHideInvitationUrl ->
StoredInvitation ->
Sem r Invitation
toInvitation isPersonalUserMigration showUrl storedInv = do
url <-
if isPersonalUserMigration
then mkInviteUrlPersonalUser showUrl storedInv.teamId storedInv.code
else mkInviteUrl showUrl storedInv.teamId storedInv.code
pure $
Invitation
{ team = storedInv.teamId,
role = fromMaybe defaultRole storedInv.role,
invitationId = storedInv.invitationId,
createdAt = storedInv.createdAt,
createdBy = storedInv.createdBy,
inviteeEmail = storedInv.email,
inviteeName = storedInv.name,
inviteeUrl = url
}

getInviteUrl ::
forall r.
(Member TinyLog r) =>
Expand Down Expand Up @@ -308,19 +283,6 @@ mkInviteUrl ShowInvitationUrl team (InvitationCode c) = do
template <- invitationEmail <$> input
getInviteUrl template team c

mkInviteUrlPersonalUser ::
( Member TinyLog r,
Member (Input TeamTemplates) r
) =>
ShowOrHideInvitationUrl ->
TeamId ->
InvitationCode ->
Sem r (Maybe (URIRef Absolute))
mkInviteUrlPersonalUser HideInvitationUrl _ _ = pure Nothing
mkInviteUrlPersonalUser ShowInvitationUrl team (InvitationCode c) = do
template <- existingUserInvitationEmail <$> input
getInviteUrl template team c

getInvitation ::
( Member GalleyAPIAccess r,
Member InvitationStore r,
Expand Down

0 comments on commit bd445d0

Please sign in to comment.