Skip to content
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

feat: Add support for stars events #241

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/models/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ mod channel;
pub use channel::*;
mod reaction;
pub use reaction::*;
mod star;
pub use star::*;

mod bot;
pub use bot::*;
Expand Down
66 changes: 66 additions & 0 deletions src/models/common/star.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
use crate::*;

use rsb_derive::Builder;
use rvstruct::ValueStruct;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
#[serde(rename_all = "lowercase")]
#[allow(clippy::large_enum_variant)]
pub enum SlackStarsItem {
Message(SlackStarsItemMessage),
File(SlackStarsItemFile),
#[serde(rename = "file_comment")]
FileComment(SlackStarsItemFileComment),
Channel(SlackStarsItemChannel),
Im(SlackStarsItemIm),
Group(SlackStarsItemGroup),
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackStarsItemMessage {
message: SlackHistoryMessage,
channel: SlackChannelId,
date_create: SlackDateTime,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackStarsItemFile {
file: SlackFile,
channel: SlackChannelId,
date_create: SlackDateTime,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackStarsItemFileComment {
file: SlackFile,
comment: String,
channel: SlackChannelId,
date_create: SlackDateTime,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackStarsItemChannel {
channel: SlackChannelId,
date_create: SlackDateTime,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackStarsItemIm {
channel: SlackChannelId,
date_create: SlackDateTime,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackStarsItemGroup {
group: SlackChannelId,
date_create: SlackDateTime,
}
18 changes: 18 additions & 0 deletions src/models/events/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub enum SlackEventCallbackBody {
FilePublic(SlackFilePublicEvent),
ReactionAdded(SlackReactionAddedEvent),
ReactionRemoved(SlackReactionRemovedEvent),
StarAdded(SlackStarAddedEvent),
StarRemoved(SlackStarRemovedEvent),
UserChange(SlackUserChangeEvent),
UserStatusChanged(SlackUserStatusChangedEvent),
}
Expand Down Expand Up @@ -356,6 +358,22 @@ pub struct SlackReactionRemovedEvent {
pub event_ts: SlackTs,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackStarAddedEvent {
pub user: SlackUserId,
pub item: SlackStarsItem,
pub event_ts: SlackTs,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackStarRemovedEvent {
pub user: SlackUserId,
pub item: SlackStarsItem,
pub event_ts: SlackTs,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackUserChangeEvent {
Expand Down