diff --git a/cabal.project b/cabal.project index 9b82856f8e..9c1b8a8c8d 100644 --- a/cabal.project +++ b/cabal.project @@ -12,7 +12,7 @@ constraints: zip +disable-bzip2 +disable-zstd source-repository-package type: git location: https://codeberg.org/s1m/sxmq.git - tag: f5720a254104d70b33ac1479ffa9d24ba9988b59 + tag: a9ef465c0af3829c58fb5e45627d9673aa5b1ee7 -- source-repository-package -- type: git diff --git a/scripts/nix/sha256map.nix b/scripts/nix/sha256map.nix index ffdf834552..d4dfe1e5c2 100644 --- a/scripts/nix/sha256map.nix +++ b/scripts/nix/sha256map.nix @@ -1,5 +1,5 @@ { - "https://codeberg.org/s1m/sxmq.git"."f5720a254104d70b33ac1479ffa9d24ba9988b59" = "cf9a74de0d05afa60a74aa8aa54205c718286b9c16c5f0f398a24d7fa7f7b1ff"; + "https://codeberg.org/s1m/sxmq.git"."a9ef465c0af3829c58fb5e45627d9673aa5b1ee7" = "5921e554cd08372335a415d7c6edcb8d83893f77fffcf5370edaaff7fe47bea6"; "https://github.com/simplex-chat/simplexmq.git"."d352d518c2b3a42bc7a298954dde799422e1457f" = "1rha84pfpaqx3mf218szkfra334vhijqf17hanxqmp1sicfbf1x3"; "https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38"; "https://github.com/simplex-chat/direct-sqlcipher.git"."f814ee68b16a9447fbb467ccc8f29bdd3546bfd9" = "1ql13f4kfwkbaq7nygkxgw84213i0zm7c1a8hwvramayxl38dq5d"; diff --git a/simplex-chat.cabal b/simplex-chat.cabal index 553f2ec6cd..c889eb3c74 100644 --- a/simplex-chat.cabal +++ b/simplex-chat.cabal @@ -238,6 +238,7 @@ library Simplex.Chat.Store.SQLite.Migrations.M20250402_short_links Simplex.Chat.Store.SQLite.Migrations.M20250512_member_admission Simplex.Chat.Store.SQLite.Migrations.M20250513_group_scope + Simplex.Chat.Store.SQLite.Migrations.M20250815_extras other-modules: Paths_simplex_chat hs-source-dirs: diff --git a/src/Simplex/Chat/Store/Profiles.hs b/src/Simplex/Chat/Store/Profiles.hs index 6678f85e53..ec11845d46 100644 --- a/src/Simplex/Chat/Store/Profiles.hs +++ b/src/Simplex/Chat/Store/Profiles.hs @@ -109,7 +109,7 @@ import qualified Simplex.Messaging.Crypto as C import qualified Simplex.Messaging.Crypto.Ratchet as CR import Simplex.Messaging.Encoding.String import Simplex.Messaging.Parsers (defaultJSON) -import Simplex.Messaging.Protocol (BasicAuth (..), ProtoServerWithAuth (..), ProtocolServer (..), ProtocolType (..), ProtocolTypeI (..), SProtocolType (..), SubscriptionMode) +import Simplex.Messaging.Protocol (BasicAuth (..), ProtoServerWithAuth (..), ProtocolServer (..), ProtocolType (..), ProtocolTypeI (..), SProtocolType (..), SubscriptionMode, Extras) import Simplex.Messaging.Transport.Client (TransportHost) import Simplex.Messaging.Util (eitherToMaybe, safeDecodeUtf8) #if defined(dbPostgres) @@ -571,15 +571,15 @@ getProtocolServers db p User {userId} = <$> DB.query db [sql| - SELECT smp_server_id, host, port, key_hash, basic_auth, preset, tested, enabled + SELECT smp_server_id, host, port, key_hash, extras, basic_auth, preset, tested, enabled FROM protocol_servers WHERE user_id = ? AND protocol = ? |] (userId, decodeLatin1 $ strEncode p) where - toUserServer :: (DBEntityId, NonEmpty TransportHost, String, C.KeyHash, Maybe Text, BoolInt, Maybe BoolInt, BoolInt) -> UserServer p - toUserServer (serverId, host, port, keyHash, auth_, BI preset, tested, BI enabled) = - let server = ProtoServerWithAuth (ProtocolServer p host port keyHash) (BasicAuth . encodeUtf8 <$> auth_) + toUserServer :: (DBEntityId, NonEmpty TransportHost, String, C.KeyHash, Maybe Extras, Maybe Text, BoolInt, Maybe BoolInt, BoolInt) -> UserServer p + toUserServer (serverId, host, port, keyHash, extras, auth_, BI preset, tested, BI enabled) = + let server = ProtoServerWithAuth (ProtocolServer p host port keyHash extras) (BasicAuth . encodeUtf8 <$> auth_) in UserServer {serverId, server, preset, tested = unBI <$> tested, enabled, deleted = False} insertProtocolServer :: forall p. ProtocolTypeI p => DB.Connection -> SProtocolType p -> User -> UTCTime -> NewUserServer p -> IO (UserServer p) @@ -588,8 +588,8 @@ insertProtocolServer db p User {userId} ts srv@UserServer {server, preset, teste db [sql| INSERT INTO protocol_servers - (protocol, host, port, key_hash, basic_auth, preset, tested, enabled, user_id, created_at, updated_at) - VALUES (?,?,?,?,?,?,?,?,?,?,?) + (protocol, host, port, key_hash, extras, basic_auth, preset, tested, enabled, user_id, created_at, updated_at) + VALUES (?,?,?,?,?,?,?,?,?,?,?,?) |] (serverColumns p server :. (BI preset, BI <$> tested, BI enabled, userId, ts, ts)) sId <- insertedRowId db @@ -601,17 +601,17 @@ updateProtocolServer db p ts UserServer {serverId, server, preset, tested, enabl db [sql| UPDATE protocol_servers - SET protocol = ?, host = ?, port = ?, key_hash = ?, basic_auth = ?, + SET protocol = ?, host = ?, port = ?, key_hash = ?, extras = ?, basic_auth = ?, preset = ?, tested = ?, enabled = ?, updated_at = ? WHERE smp_server_id = ? |] (serverColumns p server :. (BI preset, BI <$> tested, BI enabled, ts, serverId)) -serverColumns :: ProtocolTypeI p => SProtocolType p -> ProtoServerWithAuth p -> (Text, NonEmpty TransportHost, String, C.KeyHash, Maybe Text) -serverColumns p (ProtoServerWithAuth ProtocolServer {host, port, keyHash} auth_) = +serverColumns :: ProtocolTypeI p => SProtocolType p -> ProtoServerWithAuth p -> (Text, NonEmpty TransportHost, String, C.KeyHash, Maybe Extras, Maybe Text) +serverColumns p (ProtoServerWithAuth ProtocolServer {host, port, keyHash, extras} auth_) = let protocol = decodeLatin1 $ strEncode p auth = safeDecodeUtf8 . unBasicAuth <$> auth_ - in (protocol, host, port, keyHash, auth) + in (protocol, host, port, keyHash, extras, auth) getServerOperators :: DB.Connection -> ExceptT StoreError IO ServerOperatorConditions getServerOperators db = do diff --git a/src/Simplex/Chat/Store/SQLite/Migrations.hs b/src/Simplex/Chat/Store/SQLite/Migrations.hs index 871cb62220..dafb1fc717 100644 --- a/src/Simplex/Chat/Store/SQLite/Migrations.hs +++ b/src/Simplex/Chat/Store/SQLite/Migrations.hs @@ -131,6 +131,7 @@ import Simplex.Chat.Store.SQLite.Migrations.M20250130_indexes import Simplex.Chat.Store.SQLite.Migrations.M20250402_short_links import Simplex.Chat.Store.SQLite.Migrations.M20250512_member_admission import Simplex.Chat.Store.SQLite.Migrations.M20250513_group_scope +import Simplex.Chat.Store.SQLite.Migrations.M20250815_extras import Simplex.Messaging.Agent.Store.Shared (Migration (..)) schemaMigrations :: [(String, Query, Maybe Query)] @@ -261,7 +262,8 @@ schemaMigrations = ("20250130_indexes", m20250130_indexes, Just down_m20250130_indexes), ("20250402_short_links", m20250402_short_links, Just down_m20250402_short_links), ("20250512_member_admission", m20250512_member_admission, Just down_m20250512_member_admission), - ("20250513_group_scope", m20250513_group_scope, Just down_m20250513_group_scope) + ("20250513_group_scope", m20250513_group_scope, Just down_m20250513_group_scope), + ("20250815_extras", m20250815_extras, Just down_m20250815_extras) ] -- | The list of migrations in ascending order by date diff --git a/src/Simplex/Chat/Store/SQLite/Migrations/M20250815_extras.hs b/src/Simplex/Chat/Store/SQLite/Migrations/M20250815_extras.hs new file mode 100644 index 0000000000..fb6233af40 --- /dev/null +++ b/src/Simplex/Chat/Store/SQLite/Migrations/M20250815_extras.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE QuasiQuotes #-} + +module Simplex.Chat.Store.SQLite.Migrations.M20250815_extras where + +import Database.SQLite.Simple (Query) +import Database.SQLite.Simple.QQ (sql) + +m20250815_extras :: Query +m20250815_extras = + [sql| +ALTER TABLE protocol_servers ADD COLUMN extras TEXT; +|] + +down_m20250815_extras :: Query +down_m20250815_extras = + [sql| +ALTER TABLE protocol_servers DROP COLUMN extras; +|] diff --git a/src/Simplex/Chat/Store/SQLite/Migrations/chat_schema.sql b/src/Simplex/Chat/Store/SQLite/Migrations/chat_schema.sql index 91670ffc7b..33e0aa9069 100644 --- a/src/Simplex/Chat/Store/SQLite/Migrations/chat_schema.sql +++ b/src/Simplex/Chat/Store/SQLite/Migrations/chat_schema.sql @@ -464,6 +464,7 @@ CREATE TABLE IF NOT EXISTS "protocol_servers"( host TEXT NOT NULL, port TEXT NOT NULL, key_hash BLOB NOT NULL, + extras TEXT, basic_auth TEXT, preset INTEGER NOT NULL DEFAULT 0, tested INTEGER,