"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "services/brig/src/Brig/API/Util.hs" between
wire-server-2020-06-10.tar.gz and wire-server-2020-06-19.tar.gz

About: Wire (server) offers end-to-end encrypted messaging, file-sharing, video and voice calls, and guest rooms for external communication (back-end server).

Util.hs  (wire-server-2020-06-10):Util.hs  (wire-server-2020-06-19)
skipping to change at line 23 skipping to change at line 23
-- details. -- details.
-- --
-- You should have received a copy of the GNU Affero General Public License alon g -- You should have received a copy of the GNU Affero General Public License alon g
-- with this program. If not, see <https://www.gnu.org/licenses/>. -- with this program. If not, see <https://www.gnu.org/licenses/>.
module Brig.API.Util where module Brig.API.Util where
import Brig.API.Handler import Brig.API.Handler
import Brig.App (Env, settings) import Brig.App (Env, settings)
import qualified Brig.Data.User as Data import qualified Brig.Data.User as Data
import Brig.Options (defEnableFederation, enableFederation) import Brig.Options (enableFederationWithDomain)
import Brig.Types import Brig.Types
import Control.Lens (view) import Control.Lens (view)
import Control.Monad import Control.Monad
import Data.Domain (Domain)
import Data.Id as Id import Data.Id as Id
import Data.IdMapping (MappedOrLocalId (Local)) import Data.IdMapping (MappedOrLocalId (Local))
import Data.Maybe import Data.Maybe
import Imports import Imports
lookupProfilesMaybeFilterSameTeamOnly :: UserId -> [UserProfile] -> Handler [Use rProfile] lookupProfilesMaybeFilterSameTeamOnly :: UserId -> [UserProfile] -> Handler [Use rProfile]
lookupProfilesMaybeFilterSameTeamOnly self us = do lookupProfilesMaybeFilterSameTeamOnly self us = do
selfTeam <- lift $ Data.lookupUserTeam self selfTeam <- lift $ Data.lookupUserTeam self
return $ case selfTeam of return $ case selfTeam of
Just team -> filter (\x -> profileTeam x == Just team) us Just team -> filter (\x -> profileTeam x == Just team) us
Nothing -> us Nothing -> us
--------------------------------------------------------------------------------
-- Federation
viewFederationDomain :: MonadReader Env m => m (Maybe Domain)
viewFederationDomain = view (settings . enableFederationWithDomain)
isFederationEnabled :: MonadReader Env m => m Bool
isFederationEnabled = isJust <$> viewFederationDomain
-- FUTUREWORK(federation, #1178): implement function to resolve IDs in batch -- FUTUREWORK(federation, #1178): implement function to resolve IDs in batch
-- | this exists as a shim to find and mark places where we need to handle 'Opaq ueUserId's. -- | this exists as a shim to find and mark places where we need to handle 'Opaq ueUserId's.
resolveOpaqueUserId :: MonadReader Env m => OpaqueUserId -> m (MappedOrLocalId I d.U) resolveOpaqueUserId :: MonadReader Env m => OpaqueUserId -> m (MappedOrLocalId I d.U)
resolveOpaqueUserId (Id opaque) = do resolveOpaqueUserId (Id opaque) = do
mEnabled <- view (settings . enableFederation) isFederationEnabled >>= \case
case fromMaybe defEnableFederation mEnabled of
False -> False ->
-- don't check the ID mapping, just assume it's local -- don't check the ID mapping, just assume it's local
pure . Local $ Id opaque pure . Local $ Id opaque
True -> True ->
-- FUTUREWORK(federation, #1178): implement database lookup -- FUTUREWORK(federation, #1178): implement database lookup
pure . Local $ Id opaque pure . Local $ Id opaque
 End of changes. 4 change blocks. 
3 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)