Skip to content

Commit

Permalink
feat: add reason to ServerMemberLeave event
Browse files Browse the repository at this point in the history
closes #314
  • Loading branch information
insertish committed Jul 10, 2024
1 parent 78cd89e commit e290d16
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/bonfire/src/events/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ impl State {
EventV1::ServerMemberJoin { .. } => {
// We will always receive ServerCreate when joining a new server.
}
EventV1::ServerMemberLeave { id, user } => {
EventV1::ServerMemberLeave { id, user, .. } => {
if user == &self.cache.user_id {
self.remove_subscription(id).await;

Expand Down
10 changes: 7 additions & 3 deletions crates/core/database/src/events/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};
use revolt_models::v0::{
AppendMessage, Channel, Emoji, FieldsChannel, FieldsMember, FieldsRole, FieldsServer,
FieldsUser, FieldsWebhook, Member, MemberCompositeKey, Message, PartialChannel, PartialMember,
PartialMessage, PartialRole, PartialServer, PartialUser, PartialWebhook, Report, Server, User,
UserSettings, Webhook,
PartialMessage, PartialRole, PartialServer, PartialUser, PartialWebhook, RemovalIntention,
Report, Server, User, UserSettings, Webhook,
};
use revolt_result::Error;

Expand Down Expand Up @@ -136,7 +136,11 @@ pub enum EventV1 {
ServerMemberJoin { id: String, user: String },

/// User left server
ServerMemberLeave { id: String, user: String },
ServerMemberLeave {
id: String,
user: String,
reason: RemovalIntention,
},

/// Server role created or updated
ServerRoleUpdate {
Expand Down
1 change: 1 addition & 0 deletions crates/core/database/src/models/server_members/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ impl Member {
EventV1::ServerMemberLeave {
id: self.id.server.to_string(),
user: self.id.user.to_string(),
reason: intention.clone().into(),
}
.p(self.id.server.to_string())
.await;
Expand Down

0 comments on commit e290d16

Please sign in to comment.