mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-17 05:55:01 +00:00
core: update version response (#1819)
* core: update version response * add simplexmq commit and version to version info * refactor
This commit is contained in:
@@ -55,6 +55,7 @@ import Simplex.Messaging.Notifications.Protocol (DeviceToken (..), NtfTknStatus)
|
||||
import Simplex.Messaging.Parsers (dropPrefix, enumJSON, parseAll, parseString, sumTypeJSON)
|
||||
import Simplex.Messaging.Protocol (AProtocolType, CorrId, MsgFlags)
|
||||
import Simplex.Messaging.TMap (TMap)
|
||||
import Simplex.Messaging.Transport (simplexMQVersion)
|
||||
import Simplex.Messaging.Transport.Client (TransportHost)
|
||||
import System.IO (Handle)
|
||||
import System.Mem.Weak (Weak)
|
||||
@@ -63,8 +64,8 @@ import UnliftIO.STM
|
||||
versionNumber :: String
|
||||
versionNumber = showVersion SC.version
|
||||
|
||||
versionStr :: String
|
||||
versionStr = "SimpleX Chat v" <> versionNumber
|
||||
versionString :: String -> String
|
||||
versionString version = "SimpleX Chat v" <> version
|
||||
|
||||
updateStr :: String
|
||||
updateStr = "To update run: curl -o- https://raw.githubusercontent.com/simplex-chat/simplex-chat/master/install.sh | bash"
|
||||
@@ -74,6 +75,29 @@ buildTimestampQ = do
|
||||
s <- formatTime defaultTimeLocale (iso8601DateFormat $ Just "%H:%M:%S") <$> runIO getCurrentTime
|
||||
[|fromString s|]
|
||||
|
||||
simplexmqCommitQ :: Q Exp
|
||||
simplexmqCommitQ = do
|
||||
s <- either error B.unpack . A.parseOnly commitHashP <$> runIO (B.readFile "./cabal.project")
|
||||
[|fromString s|]
|
||||
where
|
||||
commitHashP :: A.Parser ByteString
|
||||
commitHashP =
|
||||
A.manyTill' A.anyChar "location: https://github.com/simplex-chat/simplexmq.git"
|
||||
*> A.takeWhile (== ' ')
|
||||
*> A.endOfLine
|
||||
*> A.takeWhile (== ' ')
|
||||
*> "tag: "
|
||||
*> A.takeWhile (A.notInClass " \r\n")
|
||||
|
||||
coreVersionInfo :: String -> String -> CoreVersionInfo
|
||||
coreVersionInfo buildTimestamp simplexmqCommit =
|
||||
CoreVersionInfo
|
||||
{ version = versionNumber,
|
||||
buildTimestamp,
|
||||
simplexmqVersion = simplexMQVersion,
|
||||
simplexmqCommit
|
||||
}
|
||||
|
||||
data ChatConfig = ChatConfig
|
||||
{ agentConfig :: AgentConfig,
|
||||
yesToMigrations :: Bool,
|
||||
@@ -344,7 +368,7 @@ data ChatResponse
|
||||
| CRFileTransferStatus (FileTransfer, [Integer]) -- TODO refactor this type to FileTransferStatus
|
||||
| CRUserProfile {profile :: Profile}
|
||||
| CRUserProfileNoChange
|
||||
| CRVersionInfo {version :: String, versionInfo :: CoreVersionInfo}
|
||||
| CRVersionInfo {versionInfo :: CoreVersionInfo}
|
||||
| CRInvitation {connReqInvitation :: ConnReqInvitation}
|
||||
| CRSentConfirmation
|
||||
| CRSentInvitation {customUserProfile :: Maybe Profile}
|
||||
@@ -557,7 +581,10 @@ data ChatLogLevel = CLLDebug | CLLInfo | CLLWarning | CLLError | CLLImportant
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
data CoreVersionInfo = CoreVersionInfo
|
||||
{ buildTimestamp :: String
|
||||
{ version :: String,
|
||||
buildTimestamp :: String,
|
||||
simplexmqVersion :: String,
|
||||
simplexmqCommit :: String
|
||||
}
|
||||
deriving (Show, Generic)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user