Skip to content

Commit

Permalink
Completing the Layout of GSoC Book
Browse files Browse the repository at this point in the history
Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>
  • Loading branch information
Harshil-Jani committed Sep 20, 2023
1 parent fa339d9 commit aa51ad3
Show file tree
Hide file tree
Showing 12 changed files with 433 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,16 @@
[Version-1 : The real bridge](./chapter_5.md)
[Version-1 : Configuring bridge](./chapter_6.md)
[Version-2 : Group/Room Creation](./chatper_7.md)
[Version-2 : DM from qaul to matrix](./chatper_8.md)
[Version-2 : DM from qaul to matrix](./chatper_8.md)
[Version-2 : Invite/Remove from group](./chapter_9.md)
[Version-2 : Sending/Receiving files](./chapter_10.md)
[Version-2 : Polishing with user menu](./chapter_11.md)

---

[Chaos Communication Camp](./chapter_12.md)
[GSoC Lightening Talks 2023](./chapter_13.md)
[Matrix Communication Camp](./chapter_14.md)

---
[Closing Notes](./chapter_15.md)
1 change: 1 addition & 0 deletions src/chapter_10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Version-2 : Sending files and receiving files
187 changes: 187 additions & 0 deletions src/chapter_11.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Version-2 : Polishing with user menu

Now we were all set functionality wise to launch the very first usable bot version on the qaul community. To improve it further for the users, I have worked a bit on improving the logs on the binary, write comments in code, format the response messages to be sent over the matrix.

One major thing which we did was to improve the matrix menu for the matrix users by allowing them to write the commands to trigger qaul events from matrix.

```markdown
!qaul : Ping to check if the bot is active or not.
!help : Get the help menu in matrix for possible events.
!users : Get list of all the users on the network.
!invite {qaul_user_id} : To invite a user from the qaul into this matrix room.
!remove {qaul_user_id} : To remove a user from the qaul into this matrix room.
!group-info : Get details for the qaul group with which this matrix room is connected.
```

Here is the code explaining how we took the commands from matrix world and processed things in Qaul world.

```rust
// We don't consider message in matrix from the bot
// since it would be the response being sent from qaul.
if msg_sender != bot_matrix_id {
let msg_text = format!("{} : {}", msg_sender, msg_body);

// Send the text to qaul to process the incoming matrix message
send_qaul(msg_text, room.room_id());

// on receiving !qaul from matrix, Send message
if msg_body.contains("!qaul") {
let content = AnyMessageEventContent::RoomMessage(
MessageEventContent::text_plain(
"I am a message sent from qaul network\n",
),
);
room.send(content, None).await.unwrap();
}

// on receiving !help from matrix, Give brief of all possible commands.
if msg_body.contains("!help") {
let content = AnyMessageEventContent::RoomMessage(MessageEventContent::text_plain(
"!qaul : Ping to check if the bot is active or not.\n!users : Get list of all the users on the network.\n!invite {qaul_user_id} : To invite a user from the qaul into this matrix room.\n !remove {qaul_user_id} : To remove a user from the qaul into this matrix room.\n!group-info : Get details for the qaul group with which this matrix room is connected.",
));
room.send(content, None).await.unwrap();
}

// on receiving !qaul in matrix, Send message
if msg_body.contains("!invite") {
let matrix_user =
room.get_member(&msg_sender).await.unwrap().unwrap();
// Admin Powers
if matrix_user.power_level() == 100 {
let mut iter = msg_body.split_whitespace();
let _command = iter.next().unwrap();
// TODO : Try to return an error if userID is wrong.
let qaul_user_id = iter.next().unwrap().to_string();
let room_id_string = room.room_id().to_string();
let sender_string = msg_sender.to_string();
let request_id = format!(
"invite#{}#{}#{}",
room_id_string, sender_string, qaul_user_id
);
println!("{}", request_id);
// Create group only if the mapping between a qaul grp and matrix room doesn't exist.
// If it exist then please check if user already exist or not. If not then invite
let config = MATRIX_CONFIG.get().write().unwrap().clone();
let room_id = room.room_id();
let qaul_group_id: Option<Uuid> = find_key_for_value(
config.room_map.clone(),
room_id.clone(),
);
if qaul_group_id == None {
group::Group::create_group(
format!("{}", msg_sender.to_owned()).to_owned(),
request_id,
);
// Acknowledge about sent invitation to qaul user.
let content = AnyMessageEventContent::RoomMessage(
MessageEventContent::text_plain("User has been invited. Please wait until user accepts the invitation."),
);
room.send(content, None).await.unwrap();
} else {
// Get the list of users who are members to the given room.
group::Group::group_info(
chat::Chat::uuid_string_to_bin(
qaul_group_id.unwrap().to_string(),
)
.unwrap(),
request_id,
);
println!("The Room Mapping already exist for this room");
// Else Invite the given user in same mapping of the matrix room.
}
} else {
// Not Admin
let content = AnyMessageEventContent::RoomMessage(
MessageEventContent::text_plain(
"Only Admins can perform this operation.",
),
);
room.send(content, None).await.unwrap();
}
}

// on receiving !users-list in matrix, Send it to command line
if msg_body.contains("!users") {
users::Users::request_user_list(room.room_id().to_string());
}

// remove the people from the matrix room
if msg_body.contains("!remove") {
let matrix_user =
room.get_member(&msg_sender).await.unwrap().unwrap();
// Admin Powers
if matrix_user.power_level() == 100 {
let mut iter = msg_body.split_whitespace();
let _command = iter.next().unwrap();
// TODO : Try to return an error if userID is wrong.
let qaul_user_id = iter.next().unwrap().to_string();
let room_id_string = room.room_id().to_string();
let sender_string = msg_sender.to_string();
let request_id = format!(
"remove#{}#{}#{}",
room_id_string, sender_string, qaul_user_id
);
println!("{}", request_id);

let config = MATRIX_CONFIG.get().write().unwrap().clone();
let room_id = room.room_id();
let qaul_group_id: Option<Uuid> = find_key_for_value(
config.room_map.clone(),
room_id.clone(),
);
if qaul_group_id == None {
// No room mapping exist
let content =
AnyMessageEventContent::RoomMessage(MessageEventContent::text_plain(
"No qaul group is mapped to this Matrix room. Please invite qaul users to this room.",
));
room.send(content, None).await.unwrap();
} else {
// Check for the group information to see if user is member of the Qaul Room or not
group::Group::group_info(
chat::Chat::uuid_string_to_bin(
qaul_group_id.unwrap().to_string(),
)
.unwrap(),
request_id,
);
}
} else {
// Not Admin
let content = AnyMessageEventContent::RoomMessage(
MessageEventContent::text_plain(
"Only Admins can perform this operation.",
),
);
room.send(content, None).await.unwrap();
}
}

// on receiving !group-info in matrix, You get the details of the group information.
if msg_body.contains("!group-info") {
let config = MATRIX_CONFIG.get().write().unwrap().clone();
let room_id = room.room_id();
let qaul_group_id: Option<Uuid> =
find_key_for_value(config.room_map.clone(), room_id.clone());
if qaul_group_id == None {
// No room mapping exist
let content =
AnyMessageEventContent::RoomMessage(MessageEventContent::text_plain(
"No qaul group is mapped to this Matrix room. Please invite qaul users to this room.",
));
room.send(content, None).await.unwrap();
} else {
let request_id = format!("info#{}#_#_", room_id).to_string();
group::Group::group_info(
chat::Chat::uuid_string_to_bin(
qaul_group_id.unwrap().to_string(),
)
.unwrap(),
request_id,
);
}
}
} else {
println!("Sent the message in the matrix room by !qaul-bot");
}
```
15 changes: 15 additions & 0 deletions src/chapter_12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CHAOS Communication Camp

This is a camp for wireless mesh networks happening in Berlin. There was a Matrix Camp with few members from Element being the part of the camp. My mentor has a friend in `Element` who invited us to present our bridge.

My mentor was into the organizing team and had got no time to test the bridge. And I always tested it locally on my personal network. On the day of presentation, We were doing a live demo in front of people from Matrix on real community node which is a global node in Qaul and interconnects you with the entire qaul community.

As soon as my mentor created a new user into the community node, there was a crytography error in creating a user and the malicious peer ID was introduced into the network. By default CLI client ignores such uncertain peerID's but the code which I had written by that time was expecting correctness and was filled with `unwrap()`'s. As soon as bad ID entered into my bridge binary's database, All of my code just broke that too in a live presentation.

I took a moment and I was converting every `unwrap()` into `match` statement to just discard wrong things and not panic. But how long can you do that in a live presentation isn't it ? It was an embrassing feeling. I really thank my mentor who kept the viewers engaged into the conversation by asking matrix specific questions and explaining them out approach to create a bridge.

Then as a part of very quick solution, I have deleted the database and created a new binary user and re-run whole bridge and showed it in front of presenters all our basic working functionalities.

This presentation was a bit messy and embrassing since we have never tested on community node and were completely unaware about how a wrong peerID can create this huge of a problem for us.

In the end, The feedback which we received was kind enough and they said that the direction we have choosen is correct. We just need to fix the bugs which we just introduced for the very first time.
13 changes: 13 additions & 0 deletions src/chapter_13.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Google Summer of Code Lightening Talks

Starting from this year, Google has started an event where the Google Summer of Code contributors from various organisations would show up in an presentation and give a 3-min session about how beautiful their journey had been with the program.

I too applied for this Lightening Talk session to talk about my project and I was lucky enough to get selected as one of the 36 contributor out of 106 applications received for the talk. To be honest it was pure luck since they have mentioned that they have randomly selected the contributors.

On 19th Sept 2023, I have given my talk for 3 mins. You can find my slides below for my explaination about my work within 3 mins and my experience.

![Slide-1](./images/slide_1.png)
![Slide-2](./images/slide_2.png)
![Slide-3](./images/slide_3.png)

And I am too happy to appreciate `Google Open Source` organization to give me a gift for the lightening talk session. XD This year's contributors teased a lot to google about giving us swags or T-Shirt and they finally gave after the talk. There were options among many different items but I choosed an Insulated Travel Tumbler. Looking forward to have my hot/cold drinks into the tumbler.
3 changes: 3 additions & 0 deletions src/chapter_14.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Matrix Communication Camp

To be given on 23rd Sept 2023
15 changes: 15 additions & 0 deletions src/chapter_15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Closing Notes

This marks the completion of my Google Summer of Code 2023 project. With all the project work and the conferences I have been part of, I am thankful to my mentor who have helped me in each stage to achieve better success.

As an individual, I have evolved a lot as a different person which stormy winds flowing through my life span. But towards the end it was all worth it since I found things that gave me the correct direction and purpose [Not talking about Career].

I am happy that this GSoC project was not another bro project which was just out there for playing around and checking that if it works then it works else leave. This was a project which I started with very little knowledge but gained massive insights of various concepts. Being from a non computer science domain, I got to learn and apply core concepts which my peers never even talk about.

The best achievement in open source world in my life is that "I wrote the world's first Matrix Bridge in Rust which made it to Production." And We were invited my `Matrix Community` to showcase our work.

I would urge developers to focus on FOSS principles and keep the source code as open as possible since the growth in computer science is research oriented and that's the main reason it has the term 'science' in it. Life is too short to earn money from code. Prefer farming, cooking, gardening, plumbing etc. to earn side money but for sake of FOSS please do not write proprietary codes.

Cheers and Regards

[Harshil Jani](https://harshil.prose.sh/)
1 change: 1 addition & 0 deletions src/chapter_9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Version-2 : Invite and remove from group
Loading

0 comments on commit aa51ad3

Please sign in to comment.