-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extra muted conversation field #469
Changes from all commits
05bdfdb
d554bf5
f38af80
a702d2d
9e3ff9f
b2c9b3a
463dfa5
92f9a3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ module Galley.Types | |
, NewConvManaged (..) | ||
, NewConvUnmanaged (..) | ||
, MemberUpdate (..) | ||
, MutedStatus (..) | ||
, TypingStatus (..) | ||
, UserClientMap (..) | ||
, UserClients (..) | ||
|
@@ -66,6 +67,7 @@ import Data.Set (Set) | |
import Data.Text (Text) | ||
import Data.Time | ||
import Data.Id | ||
import Data.Int | ||
import Data.Json.Util | ||
import Data.List1 | ||
import Data.UUID (toASCIIBytes) | ||
|
@@ -286,10 +288,16 @@ newtype Accept = Accept | |
|
||
-- Members ------------------------------------------------------------------ | ||
|
||
-- The semantics of the possible different values is entirely up to clients, | ||
-- the server will not interpret this value in any way. | ||
newtype MutedStatus = MutedStatus { fromMutedStatus :: Int32 } | ||
deriving (Eq, Num, Ord, Show, FromJSON, ToJSON) | ||
|
||
data Member = Member | ||
{ memId :: !UserId | ||
, memService :: !(Maybe ServiceRef) | ||
, memOtrMuted :: !Bool | ||
, memOtrMuted :: !Bool -- ^ DEPRECATED, remove it once enough clients use `memOtrMutedStatus` | ||
, memOtrMutedStatus :: !(Maybe MutedStatus) | ||
, memOtrMutedRef :: !(Maybe Text) | ||
, memOtrArchived :: !Bool | ||
, memOtrArchivedRef :: !(Maybe Text) | ||
|
@@ -305,8 +313,11 @@ data OtherMember = OtherMember | |
instance Ord OtherMember where | ||
compare a b = compare (omId a) (omId b) | ||
|
||
-- Inbound member updates. This is what galley expects on its endpoint. See also | ||
-- 'MemberUpdateData'. | ||
data MemberUpdate = MemberUpdate | ||
{ mupOtrMute :: !(Maybe Bool) | ||
, mupOtrMuteStatus :: !(Maybe MutedStatus) | ||
, mupOtrMuteRef :: !(Maybe Text) | ||
, mupOtrArchive :: !(Maybe Bool) | ||
, mupOtrArchiveRef :: !(Maybe Text) | ||
|
@@ -381,8 +392,11 @@ data Connect = Connect | |
, cEmail :: !(Maybe Text) | ||
} deriving (Eq, Show) | ||
|
||
-- Outbound member updates. Used for events (sent over the websocket, etc.). See also | ||
-- 'MemberUpdate'. | ||
data MemberUpdateData = MemberUpdateData | ||
{ misOtrMuted :: !(Maybe Bool) | ||
, misOtrMutedStatus :: !(Maybe MutedStatus) | ||
, misOtrMutedRef :: !(Maybe Text) | ||
, misOtrArchived :: !(Maybe Bool) | ||
, misOtrArchivedRef :: !(Maybe Text) | ||
|
@@ -797,13 +811,15 @@ instance ToJSON ConversationRename where | |
instance FromJSON MemberUpdate where | ||
parseJSON = withObject "member-update object" $ \m -> do | ||
u <- MemberUpdate <$> m .:? "otr_muted" | ||
<*> m .:? "otr_muted_status" | ||
<*> m .:? "otr_muted_ref" | ||
<*> m .:? "otr_archived" | ||
<*> m .:? "otr_archived_ref" | ||
<*> m .:? "hidden" | ||
<*> m .:? "hidden_ref" | ||
|
||
unless (isJust (mupOtrMute u) | ||
|| isJust (mupOtrMuteStatus u) | ||
|| isJust (mupOtrMuteRef u) | ||
|| isJust (mupOtrArchive u) | ||
|| isJust (mupOtrArchiveRef u) | ||
|
@@ -827,6 +843,7 @@ instance ToJSON MemberUpdate where | |
instance FromJSON MemberUpdateData where | ||
parseJSON = withObject "member-update event data" $ \m -> | ||
MemberUpdateData <$> m .:? "otr_muted" | ||
<*> m .:? "otr_muted_status" | ||
<*> m .:? "otr_muted_ref" | ||
<*> m .:? "otr_archived" | ||
<*> m .:? "otr_archived_ref" | ||
|
@@ -836,6 +853,7 @@ instance FromJSON MemberUpdateData where | |
instance ToJSON MemberUpdateData where | ||
toJSON m = object | ||
$ "otr_muted" .= misOtrMuted m | ||
# "otr_muted_status" .= misOtrMutedStatus m | ||
# "otr_muted_ref" .= misOtrMutedRef m | ||
# "otr_archived" .= misOtrArchived m | ||
# "otr_archived_ref" .= misOtrArchivedRef m | ||
|
@@ -855,6 +873,7 @@ instance ToJSON Member where | |
-- ... until here | ||
|
||
, "otr_muted" .= memOtrMuted m | ||
, "otr_muted_status" .= memOtrMutedStatus m | ||
, "otr_muted_ref" .= memOtrMutedRef m | ||
, "otr_archived" .= memOtrArchived m | ||
, "otr_archived_ref" .= memOtrArchivedRef m | ||
|
@@ -867,6 +886,7 @@ instance FromJSON Member where | |
Member <$> o .: "id" | ||
<*> o .:? "service" | ||
<*> o .:? "otr_muted" .!= False | ||
<*> o .:? "otr_muted_status" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [unrelated to this PR, but perhaps easy to fix] what's the difference between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That being said, thanks for the question since it brought up an incomplete implementation on my end! |
||
<*> o .:? "otr_muted_ref" | ||
<*> o .:? "otr_archived" .!= False | ||
<*> o .:? "otr_archived_ref" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,7 @@ executable galley-schema | |
V25 | ||
V26 | ||
V27 | ||
V28 | ||
|
||
build-depends: | ||
base | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE QuasiQuotes #-} | ||
|
||
module V28 (migration) where | ||
|
||
import Cassandra.Schema | ||
import Text.RawString.QQ | ||
|
||
migration :: Migration | ||
migration = Migration 28 "Add (extra) otr muted status to member" $ | ||
schema' [r| ALTER TABLE member ADD otr_muted_status int; |] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the
Maybe
? If not, please explain difference betweenNothing
andJust 0
in comment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Maybe
is here by design; if it's a nothing, then clients have not yet set this value which is the reason why we don't want to use a default;Just 0
could meanall message types muted
or it could also meanno message types muted
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I believe you, just trying to understand:
int
in cassandra can beNULL
, which means that all bits have their default, which we don't want to know. Yes, that makes sense, thanks!