core (pq): global flag only affects new connections; api to allow PQ in old contacts (#3869)

This commit is contained in:
spaced4ndy
2024-03-06 19:06:01 +04:00
committed by GitHub
parent 64dc758ffd
commit 61a3eb32ee
4 changed files with 36 additions and 17 deletions
+2
View File
@@ -245,6 +245,7 @@ data ChatCommand
| APISetEncryptLocalFiles Bool
| SetContactMergeEnabled Bool
| APISetPQEnabled Bool
| APIAllowContactPQ ContactId
| APIExportArchive ArchiveConfig
| ExportArchive
| APIImportArchive ArchiveConfig
@@ -699,6 +700,7 @@ data ChatResponse
| CRRemoteCtrlSessionCode {remoteCtrl_ :: Maybe RemoteCtrlInfo, sessionCode :: Text}
| CRRemoteCtrlConnected {remoteCtrl :: RemoteCtrlInfo}
| CRRemoteCtrlStopped {rcsState :: RemoteCtrlSessionState, rcStopReason :: RemoteCtrlStopReason}
| CRContactPQAllowed {user :: User, contact :: Contact}
| CRContactPQEnabled {user :: User, contact :: Contact, pqEnabled :: Bool}
| CRSQLResult {rows :: [Text]}
| CRSlowSQLQueries {chatQueries :: [SlowSQLQuery], agentQueries :: [SlowSQLQuery]}
+11
View File
@@ -245,6 +245,17 @@ createIncognitoProfile_ db userId createdAt Profile {displayName, fullName, imag
(displayName, fullName, image, userId, Just True, createdAt, createdAt)
insertedRowId db
allowConnEnablePQ :: DB.Connection -> Int64 -> IO ()
allowConnEnablePQ db connId =
DB.execute
db
[sql|
UPDATE connections
SET enable_pq = 1
WHERE connection_id = ?
|]
(Only connId)
updateConnPQSndEnabled :: DB.Connection -> Int64 -> PQFlag -> IO ()
updateConnPQSndEnabled db connId pqSndEnabled =
DB.execute
+1
View File
@@ -341,6 +341,7 @@ responseToView hu@(currentRH, user_) ChatConfig {logLevel, showReactions, showRe
["remote controller " <> sShow rcId <> " session started with " <> plain ctrlDeviceName]
CRRemoteCtrlStopped {} -> ["remote controller stopped"]
CRContactPQEnabled u c pqOn -> ttyUser u [ttyContact' c <> ": post-quantum encryption " <> (if pqOn then "enabled" else "disabled")]
CRContactPQAllowed u c -> ttyUser u [ttyContact' c <> ": post-quantum encryption allowed"]
CRSQLResult rows -> map plain rows
CRSlowSQLQueries {chatQueries, agentQueries} ->
let viewQuery SlowSQLQuery {query, queryStats = SlowQueryStats {count, timeMax, timeAvg}} =