Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion changelog.d/5-internal/polysemy-store
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Add polysemy store effects and split off Cassandra specific functionality from the Galley.Data module hierarchy.
Add polysemy store effects and split off Cassandra specific functionality from the Galley.Data module hierarchy (#1890, #1906).
22 changes: 14 additions & 8 deletions services/galley/galley.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: f4fae64cc086ec4a37984b47611854d490e7d34ba17147a2e53d2b11c3ca3218
-- hash: 07288a51b3ae662362fae1279cdd4c22977ae3c8dfb4dffe1228d0da1beba2b4

name: galley
version: 0.83.0
Expand Down Expand Up @@ -46,26 +46,27 @@ library
Galley.App
Galley.Aws
Galley.Cassandra
Galley.Cassandra.Access
Galley.Cassandra.Client
Galley.Cassandra.Code
Galley.Cassandra.Conversation
Galley.Cassandra.Conversation.Members
Galley.Cassandra.ConversationList
Galley.Cassandra.CustomBackend
Galley.Cassandra.LegalHold
Galley.Cassandra.Paging
Galley.Cassandra.Queries
Galley.Cassandra.ResultSet
Galley.Cassandra.SearchVisibility
Galley.Cassandra.Services
Galley.Cassandra.Store
Galley.Cassandra.Team
Galley.Data.Access
Galley.Cassandra.TeamFeatures
Galley.Cassandra.TeamNotifications
Galley.Data.Conversation
Galley.Data.Conversation.Types
Galley.Data.CustomBackend
Galley.Data.Instances
Galley.Data.LegalHold
Galley.Data.Queries
Galley.Data.ResultSet
Galley.Cassandra.Instances
Galley.Data.Scope
Galley.Data.SearchVisibility
Galley.Data.Services
Galley.Data.TeamFeatures
Galley.Data.TeamNotifications
Expand All @@ -76,17 +77,22 @@ library
Galley.Effects.ClientStore
Galley.Effects.CodeStore
Galley.Effects.ConversationStore
Galley.Effects.CustomBackendStore
Galley.Effects.ExternalAccess
Galley.Effects.FederatorAccess
Galley.Effects.FireAndForget
Galley.Effects.GundeckAccess
Galley.Effects.LegalHoldStore
Galley.Effects.ListItems
Galley.Effects.MemberStore
Galley.Effects.Paging
Galley.Effects.RemoteConversationListStore
Galley.Effects.SearchVisibilityStore
Galley.Effects.ServiceStore
Galley.Effects.SparAccess
Galley.Effects.TeamFeatureStore
Galley.Effects.TeamMemberStore
Galley.Effects.TeamNotificationStore
Galley.Effects.TeamStore
Galley.Env
Galley.External
Expand Down
48 changes: 40 additions & 8 deletions services/galley/src/Galley/API/Create.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import Galley.API.Mapping
import Galley.API.One2One
import Galley.API.Util
import Galley.App
import Galley.Data.Access
import qualified Galley.Data.Conversation as Data
import Galley.Data.Conversation.Types
import Galley.Effects
Expand Down Expand Up @@ -73,7 +72,15 @@ import Wire.API.Team.LegalHold (LegalholdProtectee (LegalholdPlusFederationNotIm
--
-- See Note [managed conversations].
createGroupConversation ::
Members '[ConversationStore, BrigAccess, FederatorAccess, GundeckAccess, TeamStore] r =>
Members
'[ ConversationStore,
BrigAccess,
FederatorAccess,
GundeckAccess,
LegalHoldStore,
TeamStore
]
r =>
UserId ->
ConnId ->
Public.NewConvUnmanaged ->
Expand All @@ -86,15 +93,31 @@ createGroupConversation user conn wrapped@(Public.NewConvUnmanaged body) =
-- | An internal endpoint for creating managed group conversations. Will
-- throw an error for everything else.
internalCreateManagedConversationH ::
Members '[ConversationStore, BrigAccess, FederatorAccess, GundeckAccess, TeamStore] r =>
Members
'[ ConversationStore,
BrigAccess,
FederatorAccess,
GundeckAccess,
LegalHoldStore,
TeamStore
]
r =>
UserId ::: ConnId ::: JsonRequest NewConvManaged ->
Galley r Response
internalCreateManagedConversationH (zusr ::: zcon ::: req) = do
newConv <- fromJsonBody req
handleConversationResponse <$> internalCreateManagedConversation zusr zcon newConv

internalCreateManagedConversation ::
Members '[ConversationStore, BrigAccess, FederatorAccess, GundeckAccess, TeamStore] r =>
Members
'[ ConversationStore,
BrigAccess,
FederatorAccess,
GundeckAccess,
LegalHoldStore,
TeamStore
]
r =>
UserId ->
ConnId ->
NewConvManaged ->
Expand All @@ -105,7 +128,7 @@ internalCreateManagedConversation zusr zcon (NewConvManaged body) = do
Just tinfo -> createTeamGroupConv zusr zcon tinfo body

ensureNoLegalholdConflicts ::
Member TeamStore r =>
Members '[LegalHoldStore, TeamStore] r =>
[Remote UserId] ->
[UserId] ->
Galley r ()
Expand All @@ -117,7 +140,15 @@ ensureNoLegalholdConflicts remotes locals = do

-- | A helper for creating a regular (non-team) group conversation.
createRegularGroupConv ::
Members '[ConversationStore, BrigAccess, FederatorAccess, GundeckAccess, TeamStore] r =>
Members
'[ ConversationStore,
BrigAccess,
FederatorAccess,
GundeckAccess,
LegalHoldStore,
TeamStore
]
r =>
UserId ->
ConnId ->
NewConvUnmanaged ->
Expand Down Expand Up @@ -155,6 +186,7 @@ createTeamGroupConv ::
BrigAccess,
FederatorAccess,
GundeckAccess,
LegalHoldStore,
TeamStore
]
r =>
Expand Down Expand Up @@ -497,11 +529,11 @@ toUUIDs a b = do
return (a', b')

accessRole :: NewConv -> AccessRole
accessRole b = fromMaybe defRole (newConvAccessRole b)
accessRole b = fromMaybe Data.defRole (newConvAccessRole b)

access :: NewConv -> [Access]
access a = case Set.toList (newConvAccess a) of
[] -> defRegularConvAccess
[] -> Data.defRegularConvAccess
(x : xs) -> x : xs

newConvMembers :: Local x -> NewConv -> UserList UserId
Expand Down
20 changes: 12 additions & 8 deletions services/galley/src/Galley/API/CustomBackend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,41 @@ import Data.Domain (Domain)
import Galley.API.Error
import Galley.API.Util
import Galley.App
import qualified Galley.Data.CustomBackend as Data
import Galley.Effects.CustomBackendStore
import Galley.Types
import Imports hiding ((\\))
import Network.HTTP.Types
import Network.Wai
import Network.Wai.Predicate hiding (setStatus)
import Network.Wai.Utilities
import Polysemy
import qualified Wire.API.CustomBackend as Public

-- PUBLIC ---------------------------------------------------------------------

getCustomBackendByDomainH :: Domain ::: JSON -> Galley r Response
getCustomBackendByDomainH :: Member CustomBackendStore r => Domain ::: JSON -> Galley r Response
getCustomBackendByDomainH (domain ::: _) =
json <$> getCustomBackendByDomain domain

getCustomBackendByDomain :: Domain -> Galley r Public.CustomBackend
getCustomBackendByDomain :: Member CustomBackendStore r => Domain -> Galley r Public.CustomBackend
getCustomBackendByDomain domain =
Data.getCustomBackend domain >>= \case
liftSem (getCustomBackend domain) >>= \case
Nothing -> throwM (customBackendNotFound domain)
Just customBackend -> pure customBackend

-- INTERNAL -------------------------------------------------------------------

internalPutCustomBackendByDomainH :: Domain ::: JsonRequest CustomBackend -> Galley r Response
internalPutCustomBackendByDomainH ::
Member CustomBackendStore r =>
Domain ::: JsonRequest CustomBackend ->
Galley r Response
internalPutCustomBackendByDomainH (domain ::: req) = do
customBackend <- fromJsonBody req
-- simple enough to not need a separate function
Data.setCustomBackend domain customBackend
liftSem $ setCustomBackend domain customBackend
pure (empty & setStatus status201)

internalDeleteCustomBackendByDomainH :: Domain ::: JSON -> Galley r Response
internalDeleteCustomBackendByDomainH :: Member CustomBackendStore r => Domain ::: JSON -> Galley r Response
internalDeleteCustomBackendByDomainH (domain ::: _) = do
Data.deleteCustomBackend domain
liftSem $ deleteCustomBackend domain
pure (empty & setStatus status200)
1 change: 1 addition & 0 deletions services/galley/src/Galley/API/Federation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ leaveConversation ::
FederatorAccess,
FireAndForget,
GundeckAccess,
LegalHoldStore,
MemberStore,
TeamStore
]
Expand Down
Loading