"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libs/galley-types/src/Galley/Types.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).

Types.hs  (wire-server-2020-06-10):Types.hs  (wire-server-2020-06-19)
skipping to change at line 27 skipping to change at line 27
-- 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 Galley.Types module Galley.Types
( foldrOtrRecipients, ( foldrOtrRecipients,
Accept (..), Accept (..),
ConversationMeta (..), ConversationMeta (..),
-- * re-exports -- * re-exports
Conversation (..), Conversation (..),
Member (..), LocalMember,
Member,
InternalMember (..),
ConvMembers (..), ConvMembers (..),
OtherMember (..), OtherMember (..),
Connect (..), Connect (..),
NewOtrMessage (..), NewOtrMessage (..),
ClientMismatch (..), ClientMismatch (..),
OtrRecipients (..), OtrRecipients (..),
OtrFilterMissing (..), OtrFilterMissing (..),
ConvTeamInfo (..), ConvTeamInfo (..),
ConversationCode (..), ConversationCode (..),
mkConversationCode, mkConversationCode,
skipping to change at line 78 skipping to change at line 80
newInvite, newInvite,
memberUpdate, memberUpdate,
) )
where where
import Data.Aeson import Data.Aeson
import Data.Id (ClientId, ConvId, OpaqueUserId, TeamId, UserId) import Data.Id (ClientId, ConvId, OpaqueUserId, TeamId, UserId)
import Data.Json.Util ((#)) import Data.Json.Util ((#))
import qualified Data.Map.Strict as Map import qualified Data.Map.Strict as Map
import Data.Misc (Milliseconds) import Data.Misc (Milliseconds)
import Galley.Types.Conversations.Members (InternalMember (..), LocalMember, Mem ber)
import Imports import Imports
import Wire.API.Conversation import Wire.API.Conversation hiding (Member (..))
import Wire.API.Conversation.Code import Wire.API.Conversation.Code
import Wire.API.Conversation.Typing import Wire.API.Conversation.Typing
import Wire.API.CustomBackend import Wire.API.CustomBackend
import Wire.API.Event.Conversation import Wire.API.Event.Conversation
import Wire.API.Message import Wire.API.Message
import Wire.API.User (UserIdList (..)) import Wire.API.User (UserIdList (..))
import Wire.API.User.Client import Wire.API.User.Client
--------------------------------------------------------------------------------
-- ConversationMeta
data ConversationMeta = ConversationMeta data ConversationMeta = ConversationMeta
{ cmId :: !ConvId, { cmId :: !ConvId,
cmType :: !ConvType, cmType :: !ConvType,
cmCreator :: !UserId, cmCreator :: !UserId,
cmAccess :: ![Access], cmAccess :: ![Access],
cmAccessRole :: !AccessRole, cmAccessRole :: !AccessRole,
cmName :: !(Maybe Text), cmName :: !(Maybe Text),
cmTeam :: !(Maybe TeamId), cmTeam :: !(Maybe TeamId),
cmMessageTimer :: !(Maybe Milliseconds), cmMessageTimer :: !(Maybe Milliseconds),
cmReceiptMode :: !(Maybe ReceiptMode) cmReceiptMode :: !(Maybe ReceiptMode)
} }
deriving (Eq, Show) deriving (Eq, Show)
instance ToJSON ConversationMeta where
toJSON c =
object $
"id" .= cmId c
# "type" .= cmType c
# "creator" .= cmCreator c
# "access" .= cmAccess c
# "access_role" .= cmAccessRole c
# "name" .= cmName c
# "team" .= cmTeam c
# "message_timer" .= cmMessageTimer c
# "receipt_mode" .= cmReceiptMode c
# []
foldrOtrRecipients :: (OpaqueUserId -> ClientId -> Text -> a -> a) -> a -> OtrRe instance FromJSON ConversationMeta where
cipients -> a parseJSON = withObject "conversation-meta" $ \o ->
foldrOtrRecipients f a = ConversationMeta <$> o .: "id"
Map.foldrWithKey go a <*> o .: "type"
. userClientMap <*> o .: "creator"
. otrRecipientsMap <*> o .: "access"
where <*> o .: "access_role"
go u cs acc = Map.foldrWithKey (f u) acc cs <*> o .: "name"
<*> o .:? "team"
<*> o .:? "message_timer"
<*> o .:? "receipt_mode"
--------------------------------------------------------------------------------
-- Accept
-- | Request payload for accepting a 1-1 conversation. -- | Request payload for accepting a 1-1 conversation.
newtype Accept = Accept newtype Accept = Accept
{ aUser :: UserId { aUser :: UserId
} }
deriving (Eq, Show, Generic) deriving (Eq, Show, Generic)
instance FromJSON Accept where
parseJSON = withObject "accept" $ \o ->
Accept <$> o .: "user"
instance ToJSON Accept where instance ToJSON Accept where
toJSON a = toJSON a =
object object
[ "user" .= aUser a [ "user" .= aUser a
] ]
instance FromJSON ConversationMeta where instance FromJSON Accept where
parseJSON = withObject "conversation-meta" $ \o -> parseJSON = withObject "accept" $ \o ->
ConversationMeta <$> o .: "id" Accept <$> o .: "user"
<*> o .: "type"
<*> o .: "creator"
<*> o .: "access"
<*> o .: "access_role"
<*> o .: "name"
<*> o .:? "team"
<*> o .:? "message_timer"
<*> o .:? "receipt_mode"
instance ToJSON ConversationMeta where --------------------------------------------------------------------------------
toJSON c = -- utility functions
object $
"id" .= cmId c foldrOtrRecipients :: (OpaqueUserId -> ClientId -> Text -> a -> a) -> a -> OtrRe
# "type" .= cmType c cipients -> a
# "creator" .= cmCreator c foldrOtrRecipients f a =
# "access" .= cmAccess c Map.foldrWithKey go a
# "access_role" .= cmAccessRole c . userClientMap
# "name" .= cmName c . otrRecipientsMap
# "team" .= cmTeam c where
# "message_timer" .= cmMessageTimer c go u cs acc = Map.foldrWithKey (f u) acc cs
# "receipt_mode" .= cmReceiptMode c
# []
 End of changes. 9 change blocks. 
26 lines changed or deleted 37 lines changed or added

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