|
1 | 1 | use crate::email::EmailMessage; |
2 | | -use crate::models::OwnerKind; |
| 2 | +use crate::models::{OwnerKind, TrustpubData}; |
3 | 3 | use crate::schema::{crate_owners, crates, emails, users, versions}; |
4 | 4 | use crate::worker::Environment; |
5 | 5 | use anyhow::anyhow; |
@@ -74,16 +74,25 @@ impl BackgroundJob for SendPublishNotificationsJob { |
74 | 74 | let krate = &publish_details.krate; |
75 | 75 | let version = &publish_details.version; |
76 | 76 |
|
77 | | - let publisher_info = match &publish_details.publisher { |
78 | | - Some(publisher) if publisher == recipient => &format!( |
| 77 | + let publisher_info = match (&publish_details.publisher, &publish_details.trustpub_data) |
| 78 | + { |
| 79 | + (Some(publisher), _) if publisher == recipient => &format!( |
79 | 80 | " by your account (https://{domain}/users/{publisher})", |
80 | 81 | domain = ctx.config.domain_name |
81 | 82 | ), |
82 | | - Some(publisher) => &format!( |
| 83 | + (Some(publisher), _) => &format!( |
83 | 84 | " by {publisher} (https://{domain}/users/{publisher})", |
84 | 85 | domain = ctx.config.domain_name |
85 | 86 | ), |
86 | | - None => "", |
| 87 | + ( |
| 88 | + _, |
| 89 | + Some(TrustpubData::GitHub { |
| 90 | + repository, run_id, .. |
| 91 | + }), |
| 92 | + ) => &format!( |
| 93 | + " by GitHub Actions (https://github.com/{repository}/actions/runs/{run_id})", |
| 94 | + ), |
| 95 | + _ => "", |
87 | 96 | }; |
88 | 97 |
|
89 | 98 | let email = EmailMessage::from_template( |
@@ -154,6 +163,8 @@ struct PublishDetails { |
154 | 163 | publish_time: DateTime<Utc>, |
155 | 164 | #[diesel(select_expression = users::columns::gh_login.nullable())] |
156 | 165 | publisher: Option<String>, |
| 166 | + #[diesel(select_expression = versions::columns::trustpub_data.nullable())] |
| 167 | + trustpub_data: Option<TrustpubData>, |
157 | 168 | } |
158 | 169 |
|
159 | 170 | impl PublishDetails { |
|
0 commit comments