Skip to content

Commit cee5d62

Browse files
committed
fix: audit action name
1 parent 418aeb3 commit cee5d62

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

api/migrations/20260126004140_audit.up.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- no-transaction
22
CREATE TABLE audit(
33
id UUID NOT NULL PRIMARY KEY DEFAULT gen_random_uuid(),
4-
action VARCHAR,
4+
event VARCHAR,
55
user_id NUMERIC(20, 0) NOT NULL, -- u64
66
guild_id NUMERIC(20, 0), -- u64
77
old_data VARCHAR,

api/src/audit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ where
1010
let queue_url = std::env::var("SQS_URL").expect("SQS_URL must be set");
1111

1212
let new_audit = AuditMessage::new(
13-
audit.action,
13+
audit.event,
1414
audit.user_id,
1515
audit.guild_id,
1616
audit.data.old_data.map(|v: T| serde_json::to_string(&v).unwrap()),

common/src/audit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct AuditMessage<T>
1919
where
2020
T: Serialize + for<'a> Deserialize<'a>,
2121
{
22-
pub action: String,
22+
pub event: String,
2323
pub user_id: Id<UserMarker>,
2424
pub guild_id: Option<Id<GuildMarker>>,
2525
pub data: AuditData<T>
@@ -29,9 +29,9 @@ impl<T> AuditMessage<T>
2929
where
3030
T: Serialize + for<'a> Deserialize<'a>,
3131
{
32-
pub fn new(action: String, user_id: Id<UserMarker>, guild_id: Option<Id<GuildMarker>>, old_data: Option<T>, new_data: Option<T>) -> AuditMessage<T> {
32+
pub fn new(event: String, user_id: Id<UserMarker>, guild_id: Option<Id<GuildMarker>>, old_data: Option<T>, new_data: Option<T>) -> AuditMessage<T> {
3333
AuditMessage {
34-
action,
34+
event,
3535
user_id,
3636
guild_id,
3737
data: AuditData{old_data,new_data}

consumer/src/audit/models.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use common::audit::AuditMessage;
88

99
pub struct Audit {
1010
id: Option<Uuid>, // Optional for when we want to insert a new audit
11-
action: String,
11+
event: String,
1212
user_id: Id<UserMarker>,
1313
guild_id: Option<Id<GuildMarker>>,
1414
old_data: Option<String>,
@@ -17,9 +17,9 @@ pub struct Audit {
1717

1818
impl Audit {
1919
pub async fn save(&self, pg_pool: &Pool<Postgres>) {
20-
match sqlx::query("INSERT INTO audit (id, action, user_id, guild_id, old_data, new_data) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (id) DO UPDATE SET event = $2, user_id = $3, guild_id = $4, old_data = $5, new_data = $6, updated_at = CURRENT_TIMESTAMP")
20+
match sqlx::query("INSERT INTO audit (id, event, user_id, guild_id, old_data, new_data) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (id) DO UPDATE SET event = $2, user_id = $3, guild_id = $4, old_data = $5, new_data = $6, updated_at = CURRENT_TIMESTAMP")
2121
.bind(self.id)
22-
.bind(self.action.as_str())
22+
.bind(self.event.as_str())
2323
.bind(BigDecimal::from(self.user_id.into_nonzero().get()))
2424
.bind(self.guild_id.map(|id| BigDecimal::from(id.into_nonzero().get())))
2525
.bind(&self.old_data)
@@ -38,7 +38,7 @@ impl From<AuditMessage<String>> for Audit {
3838
fn from(value: AuditMessage<String>) -> Self {
3939
Audit{
4040
id: None,
41-
action: value.action,
41+
event: value.event,
4242
user_id: value.user_id,
4343
guild_id: value.guild_id,
4444
old_data: value.data.old_data,

0 commit comments

Comments
 (0)