mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-28 20:29:53 +00:00
accepted status
This commit is contained in:
parent
b030a77efa
commit
f4d9049474
7 changed files with 20 additions and 20 deletions
|
@ -164,9 +164,9 @@ acceptMemberHook
|
||||||
when (useMemberFilter img $ rejectNames a) checkName
|
when (useMemberFilter img $ rejectNames a) checkName
|
||||||
pure $
|
pure $
|
||||||
if
|
if
|
||||||
| useMemberFilter img (passCaptcha a) -> (GAManual, GRMember)
|
| useMemberFilter img (passCaptcha a) -> (GAPending, GRMember)
|
||||||
| useMemberFilter img (makeObserver a) -> (GAAuto, GRObserver)
|
| useMemberFilter img (makeObserver a) -> (GAAccepted, GRObserver)
|
||||||
| otherwise -> (GAAuto, memberRole)
|
| otherwise -> (GAAccepted, memberRole)
|
||||||
-- TODO [captcha] uncomment for testing
|
-- TODO [captcha] uncomment for testing
|
||||||
-- pure (GAManual, GRMember)
|
-- pure (GAManual, GRMember)
|
||||||
where
|
where
|
||||||
|
|
|
@ -825,11 +825,11 @@ acceptGroupJoinRequestAsync
|
||||||
user
|
user
|
||||||
gInfo@GroupInfo {groupProfile, membership, businessChat}
|
gInfo@GroupInfo {groupProfile, membership, businessChat}
|
||||||
ucr@UserContactRequest {agentInvitationId = AgentInvId invId, cReqChatVRange}
|
ucr@UserContactRequest {agentInvitationId = AgentInvId invId, cReqChatVRange}
|
||||||
gAcceptance
|
gAccepted
|
||||||
gLinkMemRole
|
gLinkMemRole
|
||||||
incognitoProfile = do
|
incognitoProfile = do
|
||||||
gVar <- asks random
|
gVar <- asks random
|
||||||
let initialStatus = acceptanceToStatus gAcceptance
|
let initialStatus = acceptanceToStatus gAccepted
|
||||||
(groupMemberId, memberId) <- withStore $ \db -> do
|
(groupMemberId, memberId) <- withStore $ \db -> do
|
||||||
liftIO $ deleteContactRequestRec db user ucr
|
liftIO $ deleteContactRequestRec db user ucr
|
||||||
createJoiningMember db gVar user gInfo ucr gLinkMemRole initialStatus
|
createJoiningMember db gVar user gInfo ucr gLinkMemRole initialStatus
|
||||||
|
@ -843,7 +843,7 @@ acceptGroupJoinRequestAsync
|
||||||
fromMemberName = displayName,
|
fromMemberName = displayName,
|
||||||
invitedMember = MemberIdRole memberId gLinkMemRole,
|
invitedMember = MemberIdRole memberId gLinkMemRole,
|
||||||
groupProfile,
|
groupProfile,
|
||||||
acceptance = Just gAcceptance,
|
accepted = Just gAccepted,
|
||||||
business = businessChat,
|
business = businessChat,
|
||||||
groupSize = Just currentMemCount
|
groupSize = Just currentMemCount
|
||||||
}
|
}
|
||||||
|
@ -903,7 +903,7 @@ acceptBusinessJoinRequestAsync
|
||||||
fromMemberName = displayName,
|
fromMemberName = displayName,
|
||||||
invitedMember = MemberIdRole memberId GRMember,
|
invitedMember = MemberIdRole memberId GRMember,
|
||||||
groupProfile = businessGroupProfile userProfile groupPreferences,
|
groupProfile = businessGroupProfile userProfile groupPreferences,
|
||||||
acceptance = Just GAAuto,
|
accepted = Just GAAccepted,
|
||||||
-- This refers to the "title member" that defines the group name and profile.
|
-- This refers to the "title member" that defines the group name and profile.
|
||||||
-- This coincides with fromMember to be current user when accepting the connecting user,
|
-- This coincides with fromMember to be current user when accepting the connecting user,
|
||||||
-- but it will be different when inviting somebody else.
|
-- but it will be different when inviting somebody else.
|
||||||
|
|
|
@ -1208,7 +1208,7 @@ processAgentMessageConn vr user@User {userId} corrId agentConnId agentMessage =
|
||||||
Just gli@GroupLinkInfo {groupId, memberRole = gLinkMemRole} -> do
|
Just gli@GroupLinkInfo {groupId, memberRole = gLinkMemRole} -> do
|
||||||
gInfo <- withStore $ \db -> getGroupInfo db vr user groupId
|
gInfo <- withStore $ \db -> getGroupInfo db vr user groupId
|
||||||
acceptMember_ <- asks $ acceptMember . chatHooks . config
|
acceptMember_ <- asks $ acceptMember . chatHooks . config
|
||||||
maybe (pure $ Right (GAAuto, gLinkMemRole)) (\am -> liftIO $ am gInfo gli p) acceptMember_ >>= \case
|
maybe (pure $ Right (GAAccepted, gLinkMemRole)) (\am -> liftIO $ am gInfo gli p) acceptMember_ >>= \case
|
||||||
Right (acceptance, useRole)
|
Right (acceptance, useRole)
|
||||||
| v < groupFastLinkJoinVersion ->
|
| v < groupFastLinkJoinVersion ->
|
||||||
messageError "processUserContactRequest: chat version range incompatible for accepting group join request"
|
messageError "processUserContactRequest: chat version range incompatible for accepting group join request"
|
||||||
|
|
|
@ -521,9 +521,9 @@ deleteContactCardKeepConn db connId Contact {contactId, profile = LocalProfile {
|
||||||
DB.execute db "DELETE FROM contact_profiles WHERE contact_profile_id = ?" (Only profileId)
|
DB.execute db "DELETE FROM contact_profiles WHERE contact_profile_id = ?" (Only profileId)
|
||||||
|
|
||||||
createGroupInvitedViaLink :: DB.Connection -> VersionRangeChat -> User -> Connection -> GroupLinkInvitation -> ExceptT StoreError IO (GroupInfo, GroupMember)
|
createGroupInvitedViaLink :: DB.Connection -> VersionRangeChat -> User -> Connection -> GroupLinkInvitation -> ExceptT StoreError IO (GroupInfo, GroupMember)
|
||||||
createGroupInvitedViaLink db vr user conn GroupLinkInvitation {fromMember, fromMemberName, invitedMember, groupProfile, acceptance, business} = do
|
createGroupInvitedViaLink db vr user conn GroupLinkInvitation {fromMember, fromMemberName, invitedMember, groupProfile, accepted, business} = do
|
||||||
let fromMemberProfile = profileFromName fromMemberName
|
let fromMemberProfile = profileFromName fromMemberName
|
||||||
initialStatus = maybe GSMemAccepted acceptanceToStatus acceptance
|
initialStatus = maybe GSMemAccepted acceptanceToStatus accepted
|
||||||
createGroupViaLink' db vr user conn fromMember fromMemberProfile invitedMember groupProfile business initialStatus
|
createGroupViaLink' db vr user conn fromMember fromMemberProfile invitedMember groupProfile business initialStatus
|
||||||
|
|
||||||
createGroupRejectedViaLink :: DB.Connection -> VersionRangeChat -> User -> Connection -> GroupLinkRejection -> ExceptT StoreError IO (GroupInfo, GroupMember)
|
createGroupRejectedViaLink :: DB.Connection -> VersionRangeChat -> User -> Connection -> GroupLinkRejection -> ExceptT StoreError IO (GroupInfo, GroupMember)
|
||||||
|
|
|
@ -668,7 +668,7 @@ data GroupLinkInvitation = GroupLinkInvitation
|
||||||
fromMemberName :: ContactName,
|
fromMemberName :: ContactName,
|
||||||
invitedMember :: MemberIdRole,
|
invitedMember :: MemberIdRole,
|
||||||
groupProfile :: GroupProfile,
|
groupProfile :: GroupProfile,
|
||||||
acceptance :: Maybe GroupAcceptance,
|
accepted :: Maybe GroupAcceptance,
|
||||||
business :: Maybe BusinessChatInfo,
|
business :: Maybe BusinessChatInfo,
|
||||||
groupSize :: Maybe Int
|
groupSize :: Maybe Int
|
||||||
}
|
}
|
||||||
|
@ -1021,8 +1021,8 @@ instance ToJSON GroupMemberStatus where
|
||||||
|
|
||||||
acceptanceToStatus :: GroupAcceptance -> GroupMemberStatus
|
acceptanceToStatus :: GroupAcceptance -> GroupMemberStatus
|
||||||
acceptanceToStatus = \case
|
acceptanceToStatus = \case
|
||||||
GAAuto -> GSMemAccepted
|
GAAccepted -> GSMemAccepted
|
||||||
GAManual -> GSMemPendingApproval
|
GAPending -> GSMemPendingApproval
|
||||||
|
|
||||||
memberActive :: GroupMember -> Bool
|
memberActive :: GroupMember -> Bool
|
||||||
memberActive m = case memberStatus m of
|
memberActive m = case memberStatus m of
|
||||||
|
|
|
@ -49,7 +49,7 @@ instance ToJSON GroupMemberRole where
|
||||||
toJSON = strToJSON
|
toJSON = strToJSON
|
||||||
toEncoding = strToJEncoding
|
toEncoding = strToJEncoding
|
||||||
|
|
||||||
data GroupAcceptance = GAAuto | GAManual deriving (Eq, Show)
|
data GroupAcceptance = GAAccepted | GAPending deriving (Eq, Show)
|
||||||
|
|
||||||
-- TODO [knocking] encoding doesn't match field type
|
-- TODO [knocking] encoding doesn't match field type
|
||||||
instance FromField GroupAcceptance where fromField = blobFieldDecoder strDecode
|
instance FromField GroupAcceptance where fromField = blobFieldDecoder strDecode
|
||||||
|
@ -58,11 +58,11 @@ instance ToField GroupAcceptance where toField = toField . strEncode
|
||||||
|
|
||||||
instance StrEncoding GroupAcceptance where
|
instance StrEncoding GroupAcceptance where
|
||||||
strEncode = \case
|
strEncode = \case
|
||||||
GAAuto -> "auto"
|
GAAccepted -> "accepted"
|
||||||
GAManual -> "manual"
|
GAPending -> "pending"
|
||||||
strDecode = \case
|
strDecode = \case
|
||||||
"auto" -> Right GAAuto
|
"accepted" -> Right GAAccepted
|
||||||
"manual" -> Right GAManual
|
"pending" -> Right GAPending
|
||||||
r -> Left $ "bad GroupAcceptance " <> B.unpack r
|
r -> Left $ "bad GroupAcceptance " <> B.unpack r
|
||||||
strP = strDecode <$?> A.takeByteString
|
strP = strDecode <$?> A.takeByteString
|
||||||
|
|
||||||
|
|
|
@ -2960,7 +2960,7 @@ testGLinkManualAcceptMember =
|
||||||
cath #> "#team hi group"
|
cath #> "#team hi group"
|
||||||
[alice, bob] *<# "#team cath> hi group"
|
[alice, bob] *<# "#team cath> hi group"
|
||||||
where
|
where
|
||||||
cfg = testCfg {chatHooks = defaultChatHooks {acceptMember = Just (\_ _ _ -> pure $ Right (GAManual, GRObserver))}}
|
cfg = testCfg {chatHooks = defaultChatHooks {acceptMember = Just (\_ _ _ -> pure $ Right (GAPending, GRObserver))}}
|
||||||
|
|
||||||
testGLinkDeletePendingMember :: HasCallStack => TestParams -> IO ()
|
testGLinkDeletePendingMember :: HasCallStack => TestParams -> IO ()
|
||||||
testGLinkDeletePendingMember =
|
testGLinkDeletePendingMember =
|
||||||
|
@ -2985,7 +2985,7 @@ testGLinkDeletePendingMember =
|
||||||
cath <## "#team: alice removed you from the group"
|
cath <## "#team: alice removed you from the group"
|
||||||
cath <## "use /d #team to delete the group"
|
cath <## "use /d #team to delete the group"
|
||||||
where
|
where
|
||||||
cfg = testCfg {chatHooks = defaultChatHooks {acceptMember = Just (\_ _ _ -> pure $ Right (GAManual, GRObserver))}}
|
cfg = testCfg {chatHooks = defaultChatHooks {acceptMember = Just (\_ _ _ -> pure $ Right (GAPending, GRObserver))}}
|
||||||
|
|
||||||
testPlanGroupLinkKnown :: HasCallStack => TestParams -> IO ()
|
testPlanGroupLinkKnown :: HasCallStack => TestParams -> IO ()
|
||||||
testPlanGroupLinkKnown =
|
testPlanGroupLinkKnown =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue