|
@@ -162,6 +162,35 @@ impl Transaction {
|
|
|
&self.id
|
|
|
}
|
|
|
|
|
|
+ /// Updates the transaction tags
|
|
|
+ pub async fn set_tags<S>(
|
|
|
+ self,
|
|
|
+ config: &Config<S>,
|
|
|
+ new_tags: Vec<String>,
|
|
|
+ reason: String,
|
|
|
+ ) -> Result<Self, Error>
|
|
|
+ where
|
|
|
+ S: Storage + Sync + Send,
|
|
|
+ {
|
|
|
+ let new_revision = Revision {
|
|
|
+ transaction_id: self.revision.transaction_id,
|
|
|
+ changelog: reason,
|
|
|
+ previous: Some(self.revision_id),
|
|
|
+ tags: new_tags,
|
|
|
+ status: self.revision.status,
|
|
|
+ created_at: Utc::now(),
|
|
|
+ };
|
|
|
+
|
|
|
+ let mut new_transaction = Transaction {
|
|
|
+ id: self.id,
|
|
|
+ revision_id: new_revision.rev_id()?,
|
|
|
+ transaction: self.transaction,
|
|
|
+ revision: new_revision,
|
|
|
+ };
|
|
|
+ new_transaction.persist(config).await?;
|
|
|
+ Ok(new_transaction)
|
|
|
+ }
|
|
|
+
|
|
|
/// Prepares a new revision to change the transaction status
|
|
|
///
|
|
|
/// If the status transaction is not allowed, it will return an error.
|