- Moxxy is fully open source. You can find the source code on Codeberg. Additionally, the code is - mirrored on GitHub. + Moxxy is fully open source. You can find the source code on Codeberg. Additionally, the code is + mirrored on GitHub.
- Feel free to join the general chat or the developer chat with your favourite XMPP client. + Feel free to join the general chat or the developer chat with your favourite XMPP client.
- {{ post.excerpt | markdownify | strip_html | truncatewords: 100 }} + GSoC Final Report: XMPP Standards Foundation - Moxxy: Implement Group Chats +
+ Hello everyone! Welcome on Moxxy’s new website. It currently does not contain +much but that may change in the future. + +
+Hello everyone! Welcome on Moxxy’s new website. It currently does not contain +much but that may change in the future.
+ +The page is built using Jekyll and TailwindCSS. You can find the page’s +source here.
+ +Hello readers!
+ +As we know, Moxxy is an experimental IM for XMPP built using Flutter. While it does have a great set of features as described here, it currently lacks support for group chats (or Multi-User-Chats). A great piece of news is that Google has accepted my proposal to add support for multi user chats in Moxxy.
+ +To implement multi user chats in Moxxy, the XEP-0045 standard will be followed and implemented. The project will run in two phases, since the major changes required will be in the moxxmpp and Moxxy codebases. First, XEP-0045 support will be added to moxxmpp with all the handlers, events and routines required to cleanly integrate the same with Moxxy. The second phase will be the UI changes in the Moxxy Flutter application, that builds upon the existing, reusable infrastructure.
+ +The usecases planned to be implemented are listed below (subject to changes before the coding period begins):
+Some extra usecases are planned in case time permits:
+The coding period for this project will begin on May 29. In case of any queries/interest, please join the following - xmpp:dev@muc.moxxy.org?join.
+ +Hello readers!
+ +Welcome back to the GSoC series of blogs. This one is about my implementation of the MUC XEP (XEP-0045) in Moxxmpp.
+ +Well, as you probably know, Moxxy is the frontend app that is being developed as a modern new XMPP client.
+ +Moxxmpp is a Dart package that is used by Moxxy for multiple XMPP services. Essentially, the conversation between Moxxy and the XMPP server is handled by Moxxmpp. It is like the middleman that helps ease the communication between the two, keeping Moxxy code clean and free from the intricacies it handles.
+ +Since my GSoC project is all about adding MUC support to Moxxy, it was essential to first add the required support in Moxxmpp before proceeding to Moxxy. This blog will give you an idea of what the responsibilities of Moxxmpp are, and why it was important to separate it from Moxxy.
+ +In the words of it’s developer, Moxxmpp is “a pure-Dart XMPP library”. Moxxmpp could be thought of as the backbone of Moxxy. The entire communication/networking part of Moxxy, i.e. how it (as a client) communicates with the user’s XMPP server is outsourced to this Dart library.
+ +Not only this, used as per it’s rules - Moxxmpp could be used by any client to perform XMPP tasks that are currently supported by it. It is a re-usable and versatile XMPP library.
+ +Listed below are some of it’s core responsibilities:
+As of June 17 2023, there are 35 such managers and 35 XEPs supported in Moxxmpp.
+As explained below, new XEP support is related to adding new managers to Moxxmpp and I will be doing the same for XEP-0045 support in Moxxy. My design plan is elaborated in the next section.
+ +Here is my implementation plan for adding XEP-0045 support to Moxxmpp.
+ +Future<Result<RoomInformation,MUCError>> queryRoomInformation(JID roomJID)
This routine will allow the users to view the features of the room. These will include whether the room is open, moderated, password protected, etc. All this will be stored in a RoomInformation object and sent back as a Result object. It is important to note that the MUC server’s address (for the ‘to’ attribute) will be parsed from the latter half of the room JID (the part post the ‘@’).
+ +The parameters of the RoomInformation class will be represented in the following way:
+ +JID roomJID
List<String> feature_list
To join/leave a room we can send an appropriate presence stanza that will handle the same for us. So we will have two simple routines for the same as well.
+ +Future<Result>bool, MUCError>> joinRoom(JID roomJID)
This routine will send a presence stanza to the MUC server asking it to join the server. It takes the roomJID
as a parameter that will essentially contain the bare JID as well as the nickname (prompted from the user) as the resource. This will be preceded by the queryRoomInformation() routine call to obtain necessary information about the room, for example: if the room is password protected (in which case the user will see a not-implemented error dialog till a time it is supported).
Important to note is that the user’s nickname will be used as the ‘resource’ in the roomJID sent by the frontend. This is because the ‘to’ attribute of a presence stanza to join a room looks as such - {local/MUC}@{domain/chat server}/{nickname}.
Future<Result<bool, MUCError>> leaveRoom(JID roomJID)
Similarly this is a routine to allow for leaving the room with a presence stanza.
+ +The boolean return type is just to allow for a simple return object with the Result type. We could move forward with a simple Future
To be able to send messages to groupchats/MUCs, the main requirement is to be able to change the type
attribute in the message stanzas from chat
to groupchat
. This can be done in one of two ways. The first way will be to change the sendMessage
routine’s description to include a type
parameter that will simply transfer over to the stanza that will be sent from moxxmpp as a string. Another was is described below, where a new extension called ConversationTypeData will be added to the StanzaHandlerExtension
object whilst calling the sendMessage routine. The former solution is simpler and will most probably be implemented. The design for both these possibilities is listed below.
The sendMessage
routine will transform from
Future<void> sendMessage(
+ JID to,
+ TypedMap<StanzaHandlerExtension> extensions,
+) async {
+ await getAttributes().sendStanza(
+ StanzaDetails(
+ Stanza.message(
+ to: to.toString(),
+ id: extensions.get<MessageIdData>()?.id,
+ type: 'chat',
+ children: _messageSendingCallbacks
+ .map((c) => c(extensions))
+ .flattened
+ .toList(),
+ ),
+ awaitable: false,
+ ),
+ );
+}
+
+
+to
+ +Future<void> sendMessage(
+ JID to,
+ TypedMap<StanzaHandlerExtension> extensions,
+ String type,
+) async {
+ await getAttributes().sendStanza(
+ StanzaDetails(
+ Stanza.message(
+ to: to.toString(),
+ id: extensions.get<MessageIdData>()?.id,
+ type: type,
+ children: _messageSendingCallbacks
+ .map((c) => c(extensions))
+ .flattened
+ .toList(),
+ ),
+ awaitable: false,
+ ),
+ );
+}
+
+
+enum ConversationType {
+ chat, groupchat, groupchatprivate
+}
+
+
+The ConversationTypeData
class essentially will act as a wrapper over the above enum.
Hence the new type attribute value will be:
+extensions.get<ConversationTypeData>()?.conversationType ==
+ ConversationType.groupchat
+ ? 'groupchat'
+ : 'chat',
+
+
+Here, ConversationTypeData
is a simple wrapper over ConversationType
so that it can be recognized as a subclass of the StanzaHandlerExtensions
class.
For private MUC messages to a single participant, the type
attribute of the message stanza should be set to chat
. This can be handled very easily in case of either solution implementation.
For MUC messages with a stanza reflecting a chat server (type: ‘groupchat’), the type in the MessageEvent will be set to ‘groupchat’ automatically. The rest will be handled similarly to 1:1 chats.
+ +Some of the miscellaneous requirements from Moxxmpp could include viewing member list, group subject, change availability status, and more. +For now, I have identified the below as the most crucial requirements for the Moxxmpp feature additions for MUC.
+ +Below are the use-cases and how they are planned to be handled:
+ +After one joins a room, the user receives a presence from all the connected users to the chat. The best way to get the member list is to capture/handle the incoming presence stanzas and send an appropriate MUCPresenceReceived
event to the UI.
This way, whenever a user joins a room, they can see the current member list, and on subsequent presence updates, also change that list.
+ +This is a very simple usecase. When a disco info query about the MUC goes out to the XMPP server, the response contains an identity node containing the chat name. This would be the best way to extract the rom subject. As of now, the queryRoomInformation
routine will be triggered from the UI and the response will be sent to the same. This will be encapsulated in a simple RoomInformation
class which is now updated as follows:
JID roomJID
List<String> feature_list
String name
Note: Changing your status seemed like a task that would be slighlty out of scope for the project duration, so that is kept as a stretch goal for now.
+ +Frontend checks while joining a room to prevent avoidable errors:
+ +Some of the possible errors that can be faced by the user in an MUC workflow are:
+ +Some challenges/room for error were noted along the way. They are enumerated below:
+ +How will Moxxy/Moxxmpp handle messages from oneself?
+ +When a user sends a message on the MUC, they receive the message themselves as well. How will moxxmpp/moxxy differentiate between other live messages and this echoed message?
+ +The solution to this problem is to use the origin-id of the message. If the origin-id of the response matches with the sent origin-id, then the message is to be ignored and not shown in the UI.
+In anonymous MUCs, one can easily act as someone else by using their nickname once they leave. How will this be handled?
+ +This is fixed by using the occupant-id property as described in XEP-0421. A user (with their unique JID) when joins the group, is assigned a unique occupant-id, which can be used to actually track which message is from which user.
+ +This makes the implementation of reactions/retractions simpler.
+How will discussion history (sent on joining an MUC) be handled when someone rejoins an MUC?
+ +When a user joins a MUC, they are sent a set of stanzas in the following order:
+ + 1. Errors (if any)
+ 2. Self presence with status code
+ 3. Room history
+ 4. Room subject
+ 5. Live message/presence updates
+
Now, when a user gets disconnected from an MUC and joins again, then the room history will be sent again as well. To prevent this history from getting appended to the conversation in the UI, we will need to wait till we receive the room subject and only then start listening for message stanzas (since room subject is sent after room history).
+In conclusion, this blog post discussed the implementation plan for adding Multi-User Chat (MUC) support, specifically XEP-0045, to Moxxmpp. Moxxmpp serves as the backbone for the Moxxy XMPP client, handling the communication between the client and XMPP server. The blog outlined the directory structure, design plan, and key routines for implementing the MUC support in Moxxmpp. It also addressed some challenges and considerations related to handling MUC features.
+ +Implementation for this has begun, and a PR is already underway. Once this PR is completed, then work will begin on the front-end and the changes will be integrated into Moxxy.
+ + +Greetings, readers!
+ +Welcome back to our series of blogs on the Google Summer of Code (GSoC) project. In this blog post, I’ll be sharing the progress made in implementing Multi-User Chat (MUC) support in Moxxy, the frontend counterpart to my GSoC project.
+ +As you may recall, Moxxy is a frontend application developed as an innovative XMPP client. To enhance its functionality, my GSoC project focuses on adding MUC support. Before diving into the Moxxy implementation, it was crucial to establish the necessary MUC support in Moxxmpp, which is highlighted in this blog.
+ +Currently, the implementation progress is to allow users to join an MUC through Moxxy, and view incoming live messages in the chat.
+ +To implement MUC support in Moxxy, we need to extend its functionality and introduce new components. Let’s outline the design plan for the MUC feature:
+ +This page will contain just 1 text field - for the nickname that the user wants to join with. It also has a button that allows us to join the MUC with said nickname. It is an additional route to the current StartChat page, if the user selects that they want to join a groupchat.
+ +This command is sent to the data layer worker (separate thread) from the UI, when the user clicks on the join groupchat button on the new join groupchat page. It contains information about the JID and the nick that the user tried to join with. This will only be sent to the worker thread if the input validations are cleared.
+ +This event is sent back as a result of the JoinGroupchatCommand. Based on whether the request succeeded or failed, it will return the new Conversation object that has just been created.
+ +Add a new GrouchatDetails table to the database containing two data items - the jid and the nick. The main reason to have a separate table for the groupchat details, instead of to just have a new nick item in the Conversation table - was to maintain the single responsibility principle.
+ +When the user fetches a conversation of type groupchat from the database, a separate call will be made that fetches the relevant groupchat details from this new table, and attaches it to the Conversation object.
+ +Changed the external helpers for the ConversationType to an enhanced enum. This allows us to include the functions within the enum.
+The MUCManager was added to the list of registered managers for Moxxy. Not only this, the OccupantIdManager was also registered which will allow for the unique occupant identification moving forward. This will be required for message reactions/retractions in an MUC.
+Added a new GroupchatService that allows for the following functions:
+ +To prevent avoidable errors, Moxxy performs frontend checks when joining a room. These checks include ensuring to validate the JID input field, and checking for empty nicknames.
+ +Possible errors that users may encounter during the MUC workflow include invalid or already in use nicknames, disallowed registration, invalid stanza format, and invalid disco info response. Moxxy will handle these errors gracefully.
+ +Here is an enumeration of the possible challenges that we could face in the future implementation, and the ones I faced in the current implementation as well:
+ +Differentiating Messages from Oneself: Moxxy/Moxxmpp need to distinguish between messages from other users and self-echoed messages. To address this, Moxxy uses the origin ID of the message. If the origin ID of the response matches the sent origin ID, the message is ignored and not displayed in the UI.
+Handling Impersonation in Anonymous MUCs: In anonymous MUCs, users can impersonate others by reusing their nicknames after leaving. To tackle this, Moxxmpp leverages the occupant ID, as described in XEP-0421. Each user joining the group receives a unique occupant ID, which helps track message origins accurately.
+Managing Discussion History on Rejoining: When a user rejoins an MUC, the room history is resent, including errors, self-presence with status code, room history, room subject, and live message/presence updates. To prevent appending duplicate history to the UI, Moxxy/Moxxmpp will have to wait until it receives the room subject before listening for message stanzas.
+In this blog post, we explored the implementation plan for adding MUC support, specifically XEP-0045, to Moxxy. Moxxmpp serves as the backbone for Moxxy’s XMPP functionality, handling communication between the client and XMPP server. We discussed the directory structure, and key routines required for MUC support in Moxxmpp. Additionally, we addressed various challenges and considerations related to MUC features.
+ +The implementation process has already commenced, with a pull request (PR) underway. Once the PR is complete, Moxxy will support joining a groupchat and listening to live messages. In further PRs, sending messages and leaving the MUC will be supported as well. The addition of MUC support will empower Moxxy users to enjoy enhanced collaboration and communication within XMPP group chats.
+ +Stay tuned for future updates on the progress of MUC support in Moxxy. Until then, happy chatting!
+ +Project: Moxxy - Implement Group Chats
+Organization: XMPP Standards Foundation
+Duration: March 2023 - August 2023
+Student: Ikjot Singh Dhody
+Mentor: Alexander
This report presents the culmination of my work on the GSoC project “Moxxy: Implement Group Chats” under the mentorship of Alexander at the XMPP Standards Foundation. Over the course of this project, I have been engaged in implementing a group chat feature for the Moxxy application, aiming to enhance its functionality and user experience.
+ +Before getting into the details of the actual project - here is a demo screencast for the implementation:
+ + + +I have outlined the features I implemented through the GSoC period below.
+The group chat feature required changes to the Moxxy codebase, as well as the moxxmpp codebase. Moxxmpp is the data worker that sends and maintains all the request requirements of the Moxxy frontend. These are the list of contributions across both projects:
+ +Outlined below are commits made across both codebases throughout the GSoC period.
+ +There were 2 PRs merged for this codebase.
+ +Serial Number | +Commit Hash | +Description | +
---|---|---|
1 | +255d0f88e0 | +feat(xep): Use cascading operation to return state | +
2 | +fa11a3a384 | +feat(xep): Checked for the occupant-id directly. | +
3 | +ac5bb9e461 | +feat(xep): Implement XEP 0421 in Moxxmpp. | +
Serial Number | +Commit Hash | +Description | +
---|---|---|
1 | +b2724aba0c | +Merge branch ‘master’ into xep_0045 | +
2 | +d3742ea156 | +feat(xep): Small fixes - MUC Example. | +
3 | +8b00e85167 | +feat(xep): Add example for XEP 0045 Moxxmpp. | +
4 | +04dfc6d2ac | +feat(xep): Replace DiscoError with StanzaError. | +
5 | +9e70e802ef | +Merge branch ‘master’ into xep_0045 | +
6 | +3ebd9b86ec | +feat(xep): Fix lint issues and use moxlib for result. | +
7 | +a873edb9ec | +feat(xep): Check for null nick before leaveRoom. | +
8 | +e6bd6d05cd | +feat(xep): Remove NOOP cache access. | +
9 | +b7d53b8f47 | +feat(xep): Add docstings for the XEP-0045 routines | +
10 | +217c3ac236 | +feat(xep): Fix cache issue with join/leaveRoom. | +
11 | +51bca6c25d | +feat(xep): XEP-0045 cache fixes. | +
12 | +8728166a4d | +feat(xep): Add cache and roomstate to MUC implementation. | +
13 | +1f1321b269 | +feat(xep): Small fixes - review cycle 1. | +
14 | +66195f66fa | +Merge branch ‘master’ into xep_0045 | +
15 | +70fdfaf16d | +feat(xep): Fix imports for xep_0045 files. | +
16 | +cd73f89e63 | +feat(xep): Remove duplicate manager string | +
17 | +05c41d3185 | +feat(xep): Refactor sendMessage to allow groupchat | +
18 | +64a8de6caa | +feat(xep): Set base for XEP 0045 implementation | +
19 | +68809469f6 | +feat(xep): Add joinRoom, leaveRoom routines. | +
20 | +762cf1c77a | +feat(xep): Set base for XEP 0045 implementation | +
Serial Number | +Commit Hash | +Description | +
---|---|---|
1 | +549e61a168 | +feat(all): Fix linter issues. | +
2 | +26bcaccd81 | +Merge branch ‘master’ into feat/groupchat | +
3 | +df5810a347 | +feat(all): Formatting change, lock file update | +
4 | +ef931c566f | +feat(all): Send messages/chat state from Moxxy to MUC. | +
5 | +a3d4883406 | +feat(all): Remove unnecessary buttons/options for MUC. | +
6 | +532f0b1bb2 | +feat(all): Formatting fix, and navigation fix. | +
7 | +a98fe0d9f3 | +feat(all): Minor fixes - strings, formatting. | +
8 | +a7c3bd507f | +Merge branch ‘master’ of https://codeberg.org/moxxy/moxxy into feat/groupchat | +
9 | +fba2cf86ae | +feat(all): Minor formatting changes. | +
10 | +af481bf465 | +feat(all): remove unnecessary comparator override. | +
11 | +e6ae8182c2 | +feat(all): Organize import in main.dart. | +
12 | +de7b9adfa6 | +feat(all): Fix user flow for joining MUC. | +
13 | +e4f98bb82f | +feat(all): Add label to nick text field. | +
14 | +56d6f97168 | +feat(all): Minor changes, fixes. | +
15 | +b0067f055f | +feat(all): Move away from exception type design. | +
16 | +bd094dfc9a | +feat(all): Remove unnecessary function. | +
17 | +7e9d7d6281 | +feat(all): Check if Groupchat exists before method. | +
18 | +2cf781459d | +feat(all): Debug mode and translatable string | +
19 | +4ff9e3c81e | +feat(all): Remove title from GroupchatDetails. | +
20 | +e337f1c579 | +feat(all): Minor refactors - naming. | +
21 | +7c840334e1 | +feat(all): Add docs to groupchat service methods. | +
22 | +06eab1d6f5 | +feat(all): Make ConversationType an enhanced enum. | +
23 | +008e816d70 | +feat(all): Rename JoinGroupchatResultEvent. | +
24 | +2bbbc164b5 | +feat(all): Remove incorrect translations. | +
25 | +11f4fd9932 | +feat(all): Add title to GroupchatDetails. | +
26 | +a1451c6fbf | +feat(all): Refactor groupchat to new object in db. | +
27 | +993da40297 | +feat(all): Complete join groupchat flow. | +
28 | +09684b1268 | +feat(all): Fix fromDatabaseJson for MUC details. | +
29 | +0abb89cf38 | +feat(all): Fix database issues with nick. | +
30 | +7880f51b76 | +feat(all): Add db support for GroupchatDetails. | +
31 | +f0a79ca0e0 | +feat(all): Add GroupchatDetails model. | +
32 | +06dcd5491b | +feat(all): Basic groupchat error handling set up. | +
33 | +3641be4f56 | +feat(all): Join room functionality complete. | +
34 | +18e28c3bbf | +feat(all): Groupchat service/bloc updated. | +
35 | +62e39bf066 | +feat(all): Set base for groupchat implementation. | +
Was able to produce a working model of groupchats in Moxxy.
+Started the design approach from scratch and pretty much stuck to it till the end gave me confidence in my design capability.
+Fruitful discussions and review cycles were conducted that allowed for a smooth GSoC experience.
+Needed to understand 2 different codebases, and the architecture of the project. This was a pretty interesting, albeit challenging task that took me a while to master.
+Managing the busy schedule with GSoC work, family, college among other things was difficult. Also, managing a job in the latter parts was also challenging but a rewarding experience.
+The complete virtual approach was slightly difficult, and although not practical - it might have been slightly better with inter-GSoC meetings.
+The future remaining work has been enlisted in this issue by my mentor here.
+ +This includes a list of improvements, bug fixes and general future requirements that will be needed to make the groupchat experience pleasurable for the users of Moxxy.
+ +Participating in GSoC has been an enriching experience. I’ve learned valuable skills, collaborated with mentors and the open-source community, and contributed to the Moxxy project. I’m grateful to XMPP Standards Foundation for this opportunity and look forward to continuing my journey in the world of open-source software development.
+ +I would like to express my gratitude to my mentor Alexander for their guidance and support throughout this project. His guidance and understanding is what allowed me to pull through and complete the GSoC with a happy mind. I also want to thank the XMPP Standards Foundation community for their encouragement and feedback.
+ +