Implement Direct Messages for Matrix
Categories
(Chat Core :: Matrix, enhancement)
Tracking
(thunderbird78 fixed)
Tracking | Status | |
---|---|---|
thunderbird78 | --- | fixed |
People
(Reporter: matrixisreal, Assigned: khushil324)
References
Details
Attachments
(4 files, 13 obsolete files)
6.22 KB,
patch
|
clokep
:
review+
|
Details | Diff | Splinter Review |
5.86 KB,
patch
|
clokep
:
review+
|
Details | Diff | Splinter Review |
7.54 KB,
patch
|
clokep
:
review+
|
Details | Diff | Splinter Review |
21.91 KB,
patch
|
clokep
:
review+
wsmwk
:
approval-comm-beta+
|
Details | Diff | Splinter Review |
Reporter | ||
Updated•8 years ago
|
Reporter | ||
Comment 1•8 years ago
|
||
Comment 2•8 years ago
|
||
Reporter | ||
Comment 3•8 years ago
|
||
Reporter | ||
Comment 4•8 years ago
|
||
Comment 5•8 years ago
|
||
Reporter | ||
Comment 6•8 years ago
|
||
Comment 7•8 years ago
|
||
Reporter | ||
Comment 8•8 years ago
|
||
Reporter | ||
Comment 9•8 years ago
|
||
Comment 10•8 years ago
|
||
Updated•8 years ago
|
Comment 11•7 years ago
|
||
Updated•6 years ago
|
Comment 12•6 years ago
|
||
Note that a rework is pending to implement canonical DMs.
I haven't read the MSC in detail, but I am pretty sure that multiple DMs per-user will still be supported.
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 13•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 14•5 years ago
|
||
Assignee | ||
Comment 15•5 years ago
|
||
Assignee | ||
Comment 16•5 years ago
|
||
Assignee | ||
Comment 17•5 years ago
|
||
Two different patches as you have asked.
Comment 18•5 years ago
|
||
Assignee | ||
Comment 19•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Comment 20•5 years ago
|
||
Assignee | ||
Comment 21•5 years ago
|
||
(In reply to Patrick Cloke [:clokep] from comment #20)
Why the additional
|| ""
here? Do we expectgetAvatarUrl
to return false?
getAvatarUrl can return null. And if we return null, it will not show anything. But we want to show the default user icon.
I think I wasn't clear with my previous comment. Setting
this._baseURL
in
the constructor makes sense, but then we should USE It everywhere else.Additionally, do we need the port on the baseURL or is just the server name
enough? Why do these two values differ?
BaseURL is used only in createClient and getAvatarUrl. createClient needs a baseURL with the correct port. We can remove the let baseURL
and add port number in this._baseURL
.
Comment 22•5 years ago
|
||
(In reply to Khushil Mistry [:khushil324] from comment #21)
(In reply to Patrick Cloke [:clokep] from comment #20)
Why the additional
|| ""
here? Do we expectgetAvatarUrl
to return false?getAvatarUrl can return null. And if we return null, it will not show anything. But we want to show the default user icon.
Got it, I didn't realize that could ever return null.
I think I wasn't clear with my previous comment. Setting
this._baseURL
in
the constructor makes sense, but then we should USE It everywhere else.Additionally, do we need the port on the baseURL or is just the server name
enough? Why do these two values differ?BaseURL is used only in createClient and getAvatarUrl. createClient needs a baseURL with the correct port. We can remove the
let baseURL
and add port number inthis._baseURL
.
Let's add the port to this._baseURL. I think we want to use the same one everywhere.
Assignee | ||
Comment 23•5 years ago
•
|
||
I have a question related to GenericConversationPrototype
.
In this patch, I am adding functionality that if you close any conversation, we will also leave that room.
close() {
this._account._client.leave(this._roomId);
this._account._roomList.delete(this._roomId);
GenericConvChatPrototype.close.call(this);
},
But when we remove the account, we just need to remove all the conversations. At that time, we don't want to leave the group/direct messaging. At that time, we need GenericConversationPrototype. So I think GenericConversationPrototype
is needed.
Assignee | ||
Comment 24•5 years ago
|
||
Assignee | ||
Comment 25•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Comment 26•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 27•5 years ago
|
||
Checkin-needed-tb for Bug-1348064_MatrixParticipant-and-MatrixConversation-2.patch
Comment 28•5 years ago
|
||
Updated•5 years ago
|
Comment 29•5 years ago
|
||
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/caeedaa95357
Implement Direct Messages: MatrixParticipant and MatrixConversation. r=clokep
Assignee | ||
Comment 30•5 years ago
•
|
||
(In reply to Patrick Cloke [:clokep] from comment #28)
I'm having a lot of trouble following this patch. It seems to do many things
all at once and it is unclear if they're all inter-related or only "kind of"
related.A couple of things I find confusing:
- We seem to be tracking the state of whether a conversation is a chat or an
IM in multiple places. Each conversation should already know what it is, I
don't think we need account level methods to check that.- This patch might be a lot simpler if we left out things like typing and
dealt with that in the future.- It looks like some variables/properties are just renamed. If we did this
as a separate patch it would make the changes in here much easier to read.
I will split typing part in the another patch to make it more readable.
This should be
GenericConvIMPrototype
.
Yes, but now we will have a common class sharing common methods. So this method will go there. There, it should be GenericConvIMPrototype.
Additionally it would be great if a bunch of these methods had comment
strings!
Sure, I will add the comments.
It would be nice to have any shared implementation between the two
conversations in a base-class. We do this for IRC, although it is a little
messy. Check GenericIRCConversation.
Agree.
Shouldn't this call
room.close()
directly?
This will be called when you are deleting the account. So you just want to close the conversation, don't want to leave the room. close
function has a functionality that we added: you will also leave the room if you click on close button.
Should this only happen if the conv is currently a direct conversation?
Right now this will also run ifconv.isChat
is true.
No, it should happen for both types of conversation. Suppose if some conversation is direct conversation according to the matrix and it has 3 participants. So it will be the group conversation for us. If one leaves, then that conversation should be the direct conversation for us also so we want to update it from group conversation to direct conversations.
This variable name doesn't really follow the format we usually use, maybe
_userToRoom would be clearer? I believe you need to set a default value for
this somewhere on the account so that if this event never occurs the code
won't break.
Whenever we connect to the server, "accountdata" will get fired at the part of the startClient.
We seem to check this twice here, which confuses me. Why do we have to check
isDMRoom + conv.isChat, shouldn't those always be in sync?
Yes, here we can remove isDMRoom(). But we are using this.isDMRoom() at three other places elsewhere we are using conv.isChat. isDMRoom and conv.isChat will not be the same in the following cases: If we have a matrix direct conversation of 3 people. It will be a group conversation for us. But if one person leaves, we should make it a direct conversation. At this time, isDMRoom() will be true as there are 2 people only in the room but the conversation would be group conversation. isDMRoom() is used at places where we want to convert the conversation from group to direct or vise versa.
There seems to be a typo in this comment.
Yes.
I'm a bit confused at why this flag is necessary. I would think knowing it
is in the room list is enough?
When you create a new room, this will also be fired: this._client.on("Room")
. But we are creating a room in the joinChat Function.
Why can't we just use
this
throughout? It should work with the arrow
functions.
Agree.
Why would roomList not exist? We should initialize it in the constructor.
roomList will be new Map()
at the starting. We are initializing it. But if it has not any element, it will be null and this.roomList.has is showing an error. This will happen when "RoomMember.name" and "RoomMember.powerLevel" is being fired before "Room". At those times, we will be updating the participants in init function of the conversation.
Assignee | ||
Comment 31•5 years ago
|
||
Assignee | ||
Comment 32•5 years ago
|
||
Comment 33•5 years ago
|
||
Unfortunately I'm still having a lot of trouble looking at this, there's a lot of pieces and I think many of them deserve comments. I'd propose doing the following:
- There's a few pieces of this patch that rename parameters from aFoo to foo. Let's just do this in a separate bug and do the entire file at once. This should make subsequent diffs much easier.
- It seems there's a separate bug that this is fixing with joining rooms on federated servers, let's put that in a separate bug.
- There are some changes around
_roomList
->roomList
(and defining it in the init and such). It is unclear to me why this is necessary, but it feels like a separate patch. - The pieces to create the
MatrixDirectConversation
object (and using the GenericMatrixConversation and such) can be a separate patch, even though the object is unused that's fine (note that code that does this looks good in the current patch, minus that it seems like theroom
getter should be moved toGenericMatrixConversation
). - The remaining bits at this point are creating the
MatrixDirectConversation
and the upgrade/downgrade between conversation types. I'm not sure if this is one or two more patches, but hopefully the above removes a lot of the surrounding diff and makes it clearer what is happening.
I'd also recommend that we move typing notifications to a completely separate bug after all this is done. I think the current patch looks good, but it seems like we should be abstracting some of the code with the other protocols.
Assignee | ||
Comment 34•5 years ago
|
||
Part 1
Assignee | ||
Comment 35•5 years ago
|
||
Part 2.
get room() {
return this._account._client.getRoom(this._roomId);
},
Facing some issues while moving above getter to GenericMatrixConversation. Showing an error that this._account
is null. This error comes before initialization of any function in the file. So it can be the problem that we can not have such getters in the Javascript variable.
Assignee | ||
Comment 36•5 years ago
|
||
Part 3.
Joining the Chat and Typing part will be uploaded in the new bugs.
Updated•5 years ago
|
Assignee | ||
Comment 37•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Comment 38•5 years ago
|
||
Assignee | ||
Comment 39•5 years ago
•
|
||
Checkin needed for the following patches in order:
Bug-1348064_roomlist-changes-1.patch
Bug-1348064_GenericMatrixConversation-MatrixDirectConversation-0.patch
Comment 40•5 years ago
|
||
Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/57cd946f5c02
update the usage of the _roomlist in the Matrix Chat. r=clokep
https://hg.mozilla.org/comm-central/rev/35574aea0982
MatrixDirectConversation and GenericMatrixConversation added in the Matrix chat. r=clokep
Comment 41•5 years ago
|
||
Assignee | ||
Comment 42•5 years ago
•
|
||
(In reply to Patrick Cloke [:clokep] from comment #41)
We should probably define
_userToRoom
on initialization to an empty object
or something.
Agree.
I'm surprised that this isn't checking _userToRoom at all? Why don't we need
to see that? Is the is_direct property the same thing?
Here, we are identifying with: me.events.member.getContent().is_direct
. When one gets invited, this flag will be there to identify if the user is invited to the direct room or not.
The roomList should immediately have the room with the flag set to joining.
Once we join we should be setting the joined flag.
Here, the problem is when we create a new room, we will not have the room id. So we can not put the conversation in the roomList Map. Once the room is created, then only we will get the roomID but "Room" listener will be fired simultaneously. So it's hard to synchronize between both.
I prefer longer names like isDirectRoom (same goes for setDMRoom ->
setDirectRoom).
Done.
Why can't we just grab the first room member like we do above?
We can be first or second in the list. It's not defined.
It might make sense to transform _userToRoom into a Set object, which
contains the IDs of the DM rooms. It would avoid this double loop here. I
know you need a Map of user -> conv ID too, but it is probably worth storing
both.
Please add a comment about why we're using the generic call here.
Done.
If we close the conversation here then the user will just see it disappear
without any info. I think we usually set the conversation to left and add
some info for the user to see.
If we left the conversation, the user will still think the conversation is working and they will carry on with their work which will cause a lot of problems to Matrix SDK. We need to have a sperate error-showing mechanism in the Chat.
Having this global state isn't good, it means we can only be joining a
single room at once. I said it above, but I think you can replace it with
the joining flag.
The problem mentioned in the above comment.
I think you can do this all in one go: roomId.split(':', 1)[0]
Done.
Must all these properties be provided? Is there not sane defaults? How did
you decide on them?
I have tried to copy them from the Riot Chat Repository.
We should be adding this to the roomList right after we make the
conversation.
Then if it fails, we need to remove it from the roomlist. So it's better to add them when it's in the right form. Also, when you create a room, we will not have a roomID to insert.
Instead of keeping track of a list and then calculating things after the
fact I'd propose that we track two variables: our potential room ID to
return and the timestamp of the most recent event for that room. For each
location where we push onto roomList we can compare the timestamps and
either: leave room ID as is, or replace it with the updated one.Then after we check the two sets of room lists we either return what we have
or null (which can be the default value for the roomId).
Yes, I have changed getDMRoomIdForUserId
and setDirectRoom
.
Will this cause any issues if userId is proto or something weird? We
should be consistent with below here: this._userToRoom[userId] || []
userId will be a string always. So don't need to worry about this.
This is part of the interface, I don't know what will happen by just adding
additional parameters here like this. Check the users of it:
https://searchfox.org/comm-central/search?q=createConversation&redirect=false
Yes, I have changed the usage. Now using getDirectConversation
at all the places.
An awful lot of the logic here is duplicated from getGroupConversation. It
might be nice to combine them if possible, there could be a getConversation
method which takes the properties as a parameter or something maybe. I'm not
100% sure what differs between them.
I don't think so. The combined function will be really large and complex to understand. So it's better to have 2 different functions to work with. We pass different parameters when we create a new room. If the room already exists and room joining logic can be combined but it will also result in if and else blocks and copy-pasting the similar code in these if-else blocks
Assignee | ||
Comment 43•5 years ago
|
||
Comment 44•5 years ago
|
||
Updated•5 years ago
|
Comment 45•5 years ago
|
||
Comment 46•5 years ago
|
||
Updated•5 years ago
|
Comment 47•5 years ago
|
||
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/9a899d0baaa0
Implement Direct Messages for Matrix. r=clokep
Comment 48•5 years ago
|
||
This bug dragged on a bit, so just to be clear, most of the patches landed in the 78 cycle. The last one landed in the 79 cycle, but is being uplifted to 78.
Comment 49•5 years ago
|
||
bugherder uplift |
Thunderbird 78.0b4:
https://hg.mozilla.org/releases/comm-beta/rev/9f7fb887944f
Updated•5 years ago
|
Description
•