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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Send team.member-join to all apps in team.
4 changes: 2 additions & 2 deletions integration/test/API/Brig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,11 +1227,11 @@ data NewApp = NewApp
instance Default NewApp where
def =
NewApp
{ name = "",
{ name = "default name",
assets = Nothing,
accentId = Nothing,
category = "other",
description = ""
description = "default description"
}

createApp :: (MakesValue creator) => creator -> String -> NewApp -> App Response
Expand Down
23 changes: 23 additions & 0 deletions integration/test/Test/Apps.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import API.Galley
import Control.Lens hiding ((.=))
import Data.Aeson.QQ.Simple
import MLS.Util
import Notifications
import SetupHelpers
import Testlib.Prelude

Expand Down Expand Up @@ -538,3 +539,25 @@ testRemoveServicesAccessRole = do
memberIds <- mapM (\m -> m %. "qualified_id.id" >>= asString) members
appId <- app %. "qualified_id.id" & asString
memberIds `shouldNotContain` [appId]

testAppReceivesMemberJoinNotification :: (HasCallStack) => App ()
testAppReceivesMemberJoinNotification = do
(owner, tid, []) <- createTeam OwnDomain 1

-- Create an app in the team
app <- bindResponse (createApp owner tid def) $ \resp -> do
resp.status `shouldMatchInt` 200
resp.json %. "user"

-- With websockets open for both owner and app, add a new regular member.
-- Both should receive the team.member-join notification.
withWebSockets [owner, app] $ \[wsOwner, wsApp] -> do
newMember <- addUserToTeam owner

memberJoinOwner <- awaitMatch isTeamMemberJoinNotif wsOwner
memberJoinOwner %. "payload.0.team" `shouldMatch` tid
memberJoinOwner %. "payload.0.data.user" `shouldMatch` objId newMember

memberJoinApp <- awaitMatch isTeamMemberJoinNotif wsApp
memberJoinApp %. "payload.0.team" `shouldMatch` tid
memberJoinApp %. "payload.0.data.user" `shouldMatch` objId newMember
6 changes: 4 additions & 2 deletions services/galley/src/Galley/API/Teams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ import Wire.API.Team.SearchVisibility
import Wire.API.Team.SearchVisibility qualified as Public
import Wire.API.Team.Size
import Wire.API.User qualified as U
import Wire.BrigAPIAccess
import Wire.BrigAPIAccess qualified as Brig
import Wire.BrigAPIAccess qualified as E
import Wire.CodeStore
Expand Down Expand Up @@ -1153,10 +1154,11 @@ addTeamMemberInternal tid origin originConn (ntmNewTeamMember -> new) = do
E.createTeamMember tid new

now <- Now.get
appIds <- getAppIdsForTeam tid
let e = newEvent tid now (EdMemberJoin (new ^. userId))
let recipients = case origin of
Just o -> userRecipient <$> o : filter (/= o) ((new ^. userId) : admins')
Nothing -> userRecipient <$> new ^. userId : admins'
Just o -> userRecipient <$> o : filter (/= o) ((new ^. userId) : admins' ++ appIds)
Nothing -> userRecipient <$> (new ^. userId) : admins' ++ appIds
pushNotifications
[ def
{ origin = Just (new ^. userId),
Expand Down