mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 12:04:11 +00:00
feat(operators): warn when no server resolves names
Mirror USWNoChatRelays: validateUserServers emits USWNoNamesServers when no enabled server of an enabled operator carries the SMP names role. noNamesServersWarns is self-contained with local predicates, matching the sibling noChatRelaysWarns; noServersErrs is untouched.
This commit is contained in:
@@ -511,7 +511,9 @@ data UserServersError
|
||||
| USEDuplicateChatRelayAddress {duplicateChatRelay :: Text, duplicateAddress :: ShortLinkContact}
|
||||
deriving (Show)
|
||||
|
||||
data UserServersWarning = USWNoChatRelays {user :: Maybe User}
|
||||
data UserServersWarning
|
||||
= USWNoChatRelays {user :: Maybe User}
|
||||
| USWNoNamesServers {user :: Maybe User}
|
||||
deriving (Show)
|
||||
|
||||
validateUserServers :: UserServersClass u' => [u'] -> [(User, [UserOperatorServers])] -> ([UserServersError], [UserServersWarning])
|
||||
@@ -552,8 +554,8 @@ validateUserServers curr others = (currUserErrs <> concatMap otherUserErrs other
|
||||
addAddress (xs, dups) x
|
||||
| any (sameShortLinkContact x) xs = (xs, x : dups)
|
||||
| otherwise = (x : xs, dups)
|
||||
currUserWarns = noChatRelaysWarns Nothing curr
|
||||
otherUserWarns (user, uss) = noChatRelaysWarns (Just user) uss
|
||||
currUserWarns = noChatRelaysWarns Nothing curr <> noNamesServersWarns Nothing curr
|
||||
otherUserWarns (user, uss) = noChatRelaysWarns (Just user) uss <> noNamesServersWarns (Just user) uss
|
||||
noChatRelaysWarns :: UserServersClass u => Maybe User -> [u] -> [UserServersWarning]
|
||||
noChatRelaysWarns user uss
|
||||
| noChatRelays opEnabled = [USWNoChatRelays user]
|
||||
@@ -561,6 +563,14 @@ validateUserServers curr others = (currUserErrs <> concatMap otherUserErrs other
|
||||
where
|
||||
noChatRelays cond = not $ any relayEnabled $ userChatRelays $ filter cond uss
|
||||
relayEnabled (AUCR _ UserChatRelay {deleted, enabled}) = enabled && not deleted
|
||||
noNamesServersWarns :: UserServersClass u => Maybe User -> [u] -> [UserServersWarning]
|
||||
noNamesServersWarns user uss
|
||||
| noNamesServers = [USWNoNamesServers user]
|
||||
| otherwise = []
|
||||
where
|
||||
noNamesServers = not $ any srvEnabled $ userServers SPSMP $ filter namesEnabled uss
|
||||
srvEnabled (AUS _ UserServer {deleted, enabled}) = enabled && not deleted
|
||||
namesEnabled = maybe True (\op@ServerOperator {enabled} -> enabled && names (operatorRoles SPSMP op)) . operator'
|
||||
userChatRelays :: UserServersClass u => [u] -> [AUserChatRelay]
|
||||
userChatRelays = map aUserChatRelay' . concatMap chatRelays'
|
||||
opEnabled :: UserServersClass u => u -> Bool
|
||||
|
||||
Reference in New Issue
Block a user