mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
core: include commit information in /v response (#1705)
This commit is contained in:
committed by
GitHub
parent
113c67ec95
commit
3d4e4e2ef9
@@ -27,6 +27,7 @@ dependencies:
|
|||||||
- email-validate == 2.3.*
|
- email-validate == 2.3.*
|
||||||
- exceptions == 0.10.*
|
- exceptions == 0.10.*
|
||||||
- filepath == 1.4.*
|
- filepath == 1.4.*
|
||||||
|
- githash == 0.1.*
|
||||||
- http-types == 0.12.*
|
- http-types == 0.12.*
|
||||||
- mtl == 2.2.*
|
- mtl == 2.2.*
|
||||||
- network >= 3.1.2.7 && < 3.2
|
- network >= 3.1.2.7 && < 3.2
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ library
|
|||||||
, email-validate ==2.3.*
|
, email-validate ==2.3.*
|
||||||
, exceptions ==0.10.*
|
, exceptions ==0.10.*
|
||||||
, filepath ==1.4.*
|
, filepath ==1.4.*
|
||||||
|
, githash ==0.1.*
|
||||||
, http-types ==0.12.*
|
, http-types ==0.12.*
|
||||||
, mtl ==2.2.*
|
, mtl ==2.2.*
|
||||||
, network >=3.1.2.7 && <3.2
|
, network >=3.1.2.7 && <3.2
|
||||||
@@ -151,6 +152,7 @@ executable simplex-bot
|
|||||||
, email-validate ==2.3.*
|
, email-validate ==2.3.*
|
||||||
, exceptions ==0.10.*
|
, exceptions ==0.10.*
|
||||||
, filepath ==1.4.*
|
, filepath ==1.4.*
|
||||||
|
, githash ==0.1.*
|
||||||
, http-types ==0.12.*
|
, http-types ==0.12.*
|
||||||
, mtl ==2.2.*
|
, mtl ==2.2.*
|
||||||
, network >=3.1.2.7 && <3.2
|
, network >=3.1.2.7 && <3.2
|
||||||
@@ -195,6 +197,7 @@ executable simplex-bot-advanced
|
|||||||
, email-validate ==2.3.*
|
, email-validate ==2.3.*
|
||||||
, exceptions ==0.10.*
|
, exceptions ==0.10.*
|
||||||
, filepath ==1.4.*
|
, filepath ==1.4.*
|
||||||
|
, githash ==0.1.*
|
||||||
, http-types ==0.12.*
|
, http-types ==0.12.*
|
||||||
, mtl ==2.2.*
|
, mtl ==2.2.*
|
||||||
, network >=3.1.2.7 && <3.2
|
, network >=3.1.2.7 && <3.2
|
||||||
@@ -240,6 +243,7 @@ executable simplex-chat
|
|||||||
, email-validate ==2.3.*
|
, email-validate ==2.3.*
|
||||||
, exceptions ==0.10.*
|
, exceptions ==0.10.*
|
||||||
, filepath ==1.4.*
|
, filepath ==1.4.*
|
||||||
|
, githash ==0.1.*
|
||||||
, http-types ==0.12.*
|
, http-types ==0.12.*
|
||||||
, mtl ==2.2.*
|
, mtl ==2.2.*
|
||||||
, network ==3.1.*
|
, network ==3.1.*
|
||||||
@@ -293,6 +297,7 @@ test-suite simplex-chat-test
|
|||||||
, email-validate ==2.3.*
|
, email-validate ==2.3.*
|
||||||
, exceptions ==0.10.*
|
, exceptions ==0.10.*
|
||||||
, filepath ==1.4.*
|
, filepath ==1.4.*
|
||||||
|
, githash ==0.1.*
|
||||||
, hspec ==2.7.*
|
, hspec ==2.7.*
|
||||||
, http-types ==0.12.*
|
, http-types ==0.12.*
|
||||||
, mtl ==2.2.*
|
, mtl ==2.2.*
|
||||||
|
|||||||
+1
-1
@@ -1207,7 +1207,7 @@ processChatCommand = \case
|
|||||||
updateGroupProfileByName gName $ \p ->
|
updateGroupProfileByName gName $ \p ->
|
||||||
p {groupPreferences = Just . setGroupPreference' SGFTimedMessages pref $ groupPreferences p}
|
p {groupPreferences = Just . setGroupPreference' SGFTimedMessages pref $ groupPreferences p}
|
||||||
QuitChat -> liftIO exitSuccess
|
QuitChat -> liftIO exitSuccess
|
||||||
ShowVersion -> pure $ CRVersionInfo versionNumber
|
ShowVersion -> pure $ CRVersionInfo versionNumber coreVersionInfo
|
||||||
DebugLocks -> do
|
DebugLocks -> do
|
||||||
chatLockName <- atomically . tryReadTMVar =<< asks chatLock
|
chatLockName <- atomically . tryReadTMVar =<< asks chatLock
|
||||||
agentLocks <- withAgent debugAgentLocks
|
agentLocks <- withAgent debugAgentLocks
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
{-# LANGUAGE NamedFieldPuns #-}
|
{-# LANGUAGE NamedFieldPuns #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE StrictData #-}
|
{-# LANGUAGE StrictData #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
|
||||||
module Simplex.Chat.Controller where
|
module Simplex.Chat.Controller where
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ import Data.Time (ZonedTime)
|
|||||||
import Data.Time.Clock (UTCTime)
|
import Data.Time.Clock (UTCTime)
|
||||||
import Data.Version (showVersion)
|
import Data.Version (showVersion)
|
||||||
import GHC.Generics (Generic)
|
import GHC.Generics (Generic)
|
||||||
|
import GitHash
|
||||||
import Numeric.Natural
|
import Numeric.Natural
|
||||||
import qualified Paths_simplex_chat as SC
|
import qualified Paths_simplex_chat as SC
|
||||||
import Simplex.Chat.Call
|
import Simplex.Chat.Call
|
||||||
@@ -61,6 +63,19 @@ import UnliftIO.STM
|
|||||||
versionNumber :: String
|
versionNumber :: String
|
||||||
versionNumber = showVersion SC.version
|
versionNumber = showVersion SC.version
|
||||||
|
|
||||||
|
coreVersionInfo :: CoreVersionInfo
|
||||||
|
coreVersionInfo =
|
||||||
|
CoreVersionInfo
|
||||||
|
{ commitHash = giHash gi,
|
||||||
|
commitDate = giCommitDate gi,
|
||||||
|
commitMessage = giCommitMessage gi,
|
||||||
|
branch = giBranch gi,
|
||||||
|
tag = giTag gi,
|
||||||
|
dirty = giDirty gi
|
||||||
|
}
|
||||||
|
where
|
||||||
|
gi = $$tGitInfoCwd
|
||||||
|
|
||||||
versionStr :: String
|
versionStr :: String
|
||||||
versionStr = "SimpleX Chat v" <> versionNumber
|
versionStr = "SimpleX Chat v" <> versionNumber
|
||||||
|
|
||||||
@@ -334,7 +349,7 @@ data ChatResponse
|
|||||||
| CRFileTransferStatus (FileTransfer, [Integer]) -- TODO refactor this type to FileTransferStatus
|
| CRFileTransferStatus (FileTransfer, [Integer]) -- TODO refactor this type to FileTransferStatus
|
||||||
| CRUserProfile {profile :: Profile}
|
| CRUserProfile {profile :: Profile}
|
||||||
| CRUserProfileNoChange
|
| CRUserProfileNoChange
|
||||||
| CRVersionInfo {version :: String}
|
| CRVersionInfo {version :: String, coreVersion :: CoreVersionInfo}
|
||||||
| CRInvitation {connReqInvitation :: ConnReqInvitation}
|
| CRInvitation {connReqInvitation :: ConnReqInvitation}
|
||||||
| CRSentConfirmation
|
| CRSentConfirmation
|
||||||
| CRSentInvitation {customUserProfile :: Maybe Profile}
|
| CRSentInvitation {customUserProfile :: Maybe Profile}
|
||||||
@@ -543,6 +558,18 @@ tmeToPref currentTTL tme = uncurry TimedMessagesPreference $ case tme of
|
|||||||
TMEEnableKeepTTL -> (FAYes, currentTTL)
|
TMEEnableKeepTTL -> (FAYes, currentTTL)
|
||||||
TMEDisableKeepTTL -> (FANo, currentTTL)
|
TMEDisableKeepTTL -> (FANo, currentTTL)
|
||||||
|
|
||||||
|
data CoreVersionInfo = CoreVersionInfo
|
||||||
|
{ commitHash :: String,
|
||||||
|
commitDate :: String,
|
||||||
|
commitMessage :: String,
|
||||||
|
branch :: String,
|
||||||
|
tag :: String,
|
||||||
|
dirty :: Bool
|
||||||
|
}
|
||||||
|
deriving (Show, Generic)
|
||||||
|
|
||||||
|
instance ToJSON CoreVersionInfo where toEncoding = J.genericToEncoding J.defaultOptions
|
||||||
|
|
||||||
data ChatError
|
data ChatError
|
||||||
= ChatError {errorType :: ChatErrorType}
|
= ChatError {errorType :: ChatErrorType}
|
||||||
| ChatErrorAgent {agentError :: AgentErrorType, connectionEntity_ :: Maybe ConnectionEntity}
|
| ChatErrorAgent {agentError :: AgentErrorType, connectionEntity_ :: Maybe ConnectionEntity}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ responseToView user_ testView liveItems ts = \case
|
|||||||
CRFileTransferStatus ftStatus -> viewFileTransferStatus ftStatus
|
CRFileTransferStatus ftStatus -> viewFileTransferStatus ftStatus
|
||||||
CRUserProfile p -> viewUserProfile p
|
CRUserProfile p -> viewUserProfile p
|
||||||
CRUserProfileNoChange -> ["user profile did not change"]
|
CRUserProfileNoChange -> ["user profile did not change"]
|
||||||
CRVersionInfo _ -> [plain versionStr, plain updateStr]
|
CRVersionInfo _ info -> [plain versionStr, viewCoreVersionInfo info, plain updateStr]
|
||||||
CRChatCmdError e -> viewChatError e
|
CRChatCmdError e -> viewChatError e
|
||||||
CRInvitation cReq -> viewConnReqInvitation cReq
|
CRInvitation cReq -> viewConnReqInvitation cReq
|
||||||
CRSentConfirmation -> ["confirmation sent!"]
|
CRSentConfirmation -> ["confirmation sent!"]
|
||||||
@@ -1127,6 +1127,10 @@ instance ToJSON WCallCommand where
|
|||||||
toEncoding = J.genericToEncoding . taggedObjectJSON $ dropPrefix "WCCall"
|
toEncoding = J.genericToEncoding . taggedObjectJSON $ dropPrefix "WCCall"
|
||||||
toJSON = J.genericToJSON . taggedObjectJSON $ dropPrefix "WCCall"
|
toJSON = J.genericToJSON . taggedObjectJSON $ dropPrefix "WCCall"
|
||||||
|
|
||||||
|
viewCoreVersionInfo :: CoreVersionInfo -> StyledString
|
||||||
|
viewCoreVersionInfo CoreVersionInfo {commitHash, commitMessage, commitDate} =
|
||||||
|
plain $ "commit " <> commitHash <> ": " <> commitMessage <> " (" <> commitDate <> ")"
|
||||||
|
|
||||||
viewChatError :: ChatError -> [StyledString]
|
viewChatError :: ChatError -> [StyledString]
|
||||||
viewChatError = \case
|
viewChatError = \case
|
||||||
ChatError err -> case err of
|
ChatError err -> case err of
|
||||||
|
|||||||
Reference in New Issue
Block a user