Skip to content

Commit

Permalink
feat: Sprint event decoration
Browse files Browse the repository at this point in the history
  • Loading branch information
MrExplode committed Nov 9, 2023
1 parent 006a6a9 commit 4a8a2f8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/jira.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde::Deserialize;
use serde_json::json;
use webhook::models::{Embed, Message};

use crate::types::Comment;
use crate::types::{Comment, Sprint};
use crate::util::{extract_event_name, log_request, root_url};
use crate::{imgstore, types::JiraData, Clients};

Expand Down Expand Up @@ -101,6 +101,10 @@ async fn create_message(data: JiraData) -> Result<Message> {
decorate_issue_embed(&mut embed, &data, issue_type_url, project_avatar_url);
}

if data.sprint.is_some() {
decorate_sprint_embed(&mut embed, data.sprint.as_ref().unwrap());
}

msg.embeds.push(embed);

if data.comment.is_some() {
Expand Down Expand Up @@ -171,3 +175,9 @@ fn decorate_comment_embed(e: &mut Embed, c: &Comment) {
)
.description(c.body.as_str());
}

fn decorate_sprint_embed(e: &mut Embed, s: &Sprint) {
e.description(format!("**{}**\n{}", s.name, s.goal).as_str())
.field("Start", &s.start_date, true)
.field("End", &s.end_date, true);
}
14 changes: 14 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct JiraData {
pub issue_event_type_name: Option<String>,
pub changelog: Option<Changelog>,
pub comment: Option<Comment>,
pub sprint: Option<Sprint>,
}

#[derive(Deserialize)]
Expand Down Expand Up @@ -104,3 +105,16 @@ pub struct Comment {
pub created: String,
pub updated: String,
}

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Sprint {
#[serde(rename = "self")]
pub self_url: String,
pub id: i32,
pub state: String,
pub name: String,
pub start_date: String,
pub end_date: String,
pub goal: String,
}

0 comments on commit 4a8a2f8

Please sign in to comment.