mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-30 21:49:14 +00:00
core: add/send contact address and request messages, ios: use auto-reply as welcome message (#6017)
* core: add/send contact address and request messages, ios: use auto-reply as welcome message * revert event type change * fix test, type * multiplatform: update type * fix query * ios: hide keyboard when sending the message * failing test for business chat with a welcome message * retry joining via contact address * query plans * do not send history to the first member (the original customer) of business chat * correctly handle retries when joining groups, do not create a new connection on retry * failing test for group welcome message and feature items * do not send history item if member saw it during joining (based on welcomeSharedMsgId in join request) * correct fields in PendingContactConnection, update plans * prevent duplicate group description created in chat, while ensuring that it is created * fix query
This commit is contained in:
@@ -431,7 +431,22 @@ deleteUnusedIncognitoProfileById_ db User {userId} profileId =
|
||||
|]
|
||||
(userId, profileId, userId, profileId, userId, profileId)
|
||||
|
||||
type PreparedContactRow = (Maybe AConnectionRequestUri, Maybe AConnShortLink, Maybe SharedMsgId)
|
||||
deleteIncognitoConnectionProfile :: DB.Connection -> UserId -> Connection -> IO ()
|
||||
deleteIncognitoConnectionProfile db userId Connection {connId, customUserProfileId} =
|
||||
forM_ customUserProfileId $ \profileId -> do
|
||||
DB.execute db "UPDATE connections SET custom_user_profile_id = NULL WHERE connection_id = ?" (Only connId)
|
||||
DB.execute
|
||||
db
|
||||
[sql|
|
||||
DELETE FROM contact_profiles
|
||||
WHERE user_id = ? AND contact_profile_id = ?
|
||||
AND NOT EXISTS (SELECT 1 FROM contacts WHERE contact_profile_id = ?)
|
||||
AND NOT EXISTS (SELECT 1 FROM contact_requests WHERE contact_profile_id = ?)
|
||||
AND NOT EXISTS (SELECT 1 FROM group_members WHERE contact_profile_id = ? OR member_profile_id = ?)
|
||||
|]
|
||||
(userId, profileId, profileId, profileId, profileId, profileId)
|
||||
|
||||
type PreparedContactRow = (Maybe AConnectionRequestUri, Maybe AConnShortLink, Maybe SharedMsgId, Maybe SharedMsgId)
|
||||
|
||||
type ContactRow' = (ProfileId, ContactName, Maybe Int64, ContactName, Text, Maybe ImageData, Maybe ConnLinkContact, LocalAlias, BoolInt, ContactStatus) :. (Maybe MsgFilter, Maybe BoolInt, BoolInt, Maybe Preferences, Preferences, UTCTime, UTCTime, Maybe UTCTime) :. PreparedContactRow :. (Maybe Int64, Maybe GroupMemberId, BoolInt, Maybe UIThemeEntityOverrides, BoolInt, Maybe CustomData, Maybe Int64)
|
||||
|
||||
@@ -448,8 +463,9 @@ toContact vr user chatTags ((Only contactId :. (profileId, localDisplayName, via
|
||||
in Contact {contactId, localDisplayName, profile, activeConn, viaGroup, contactUsed, contactStatus, chatSettings, userPreferences, mergedPreferences, createdAt, updatedAt, chatTs, preparedContact, contactRequestId, contactGroupMemberId, contactGrpInvSent, chatTags, chatItemTTL, uiThemes, chatDeleted, customData}
|
||||
|
||||
toPreparedContact :: PreparedContactRow -> Maybe PreparedContact
|
||||
toPreparedContact (connFullLink, connShortLink, welcomeSharedMsgId) =
|
||||
(\cl@(ACCL m _) -> PreparedContact cl (connMode m) welcomeSharedMsgId) <$> toACreatedConnLink_ connFullLink connShortLink
|
||||
toPreparedContact (connFullLink, connShortLink, welcomeSharedMsgId, requestSharedMsgId) =
|
||||
(\cl@(ACCL m _) -> PreparedContact {connLinkToConnect = cl, uiConnLinkType = connMode m, welcomeSharedMsgId, requestSharedMsgId})
|
||||
<$> toACreatedConnLink_ connFullLink connShortLink
|
||||
|
||||
toACreatedConnLink_ :: Maybe AConnectionRequestUri -> Maybe AConnShortLink -> Maybe ACreatedConnLink
|
||||
toACreatedConnLink_ Nothing _ = Nothing
|
||||
@@ -604,7 +620,7 @@ safeDeleteLDN db User {userId} localDisplayName = do
|
||||
|]
|
||||
(userId, localDisplayName, userId)
|
||||
|
||||
type PreparedGroupRow = (Maybe ConnReqContact, Maybe ShortLinkContact, BoolInt, Maybe SharedMsgId)
|
||||
type PreparedGroupRow = (Maybe ConnReqContact, Maybe ShortLinkContact, BoolInt, Maybe SharedMsgId, Maybe SharedMsgId)
|
||||
|
||||
type BusinessChatInfoRow = (Maybe BusinessChatType, Maybe MemberId, Maybe MemberId)
|
||||
|
||||
@@ -624,8 +640,8 @@ toGroupInfo vr userContactId chatTags ((groupId, localDisplayName, displayName,
|
||||
|
||||
toPreparedGroup :: PreparedGroupRow -> Maybe PreparedGroup
|
||||
toPreparedGroup = \case
|
||||
(Just fullLink, shortLink_, BI connLinkStartedConnection, welcomeSharedMsgId) ->
|
||||
Just PreparedGroup {connLinkToConnect = CCLink fullLink shortLink_, connLinkStartedConnection, welcomeSharedMsgId}
|
||||
(Just fullLink, shortLink_, BI connLinkStartedConnection, welcomeSharedMsgId, requestSharedMsgId) ->
|
||||
Just PreparedGroup {connLinkToConnect = CCLink fullLink shortLink_, connLinkStartedConnection, welcomeSharedMsgId, requestSharedMsgId}
|
||||
_ -> Nothing
|
||||
|
||||
toGroupMember :: Int64 -> GroupMemberRow -> GroupMember
|
||||
@@ -660,7 +676,7 @@ groupInfoQuery =
|
||||
g.group_id, g.local_display_name, gp.display_name, gp.full_name, g.local_alias, gp.description, gp.image,
|
||||
g.enable_ntfs, g.send_rcpts, g.favorite, gp.preferences, gp.member_admission,
|
||||
g.created_at, g.updated_at, g.chat_ts, g.user_member_profile_sent_at,
|
||||
g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_started_connection, g.welcome_shared_msg_id,
|
||||
g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_started_connection, g.welcome_shared_msg_id, g.request_shared_msg_id,
|
||||
g.business_chat, g.business_member_id, g.customer_member_id,
|
||||
g.ui_themes, g.custom_data, g.chat_item_ttl, g.members_require_attention,
|
||||
-- GroupMember - membership
|
||||
|
||||
Reference in New Issue
Block a user