blob: 845db2cdd32738d3fdd0b2416be2209545c54d6d [file] [log] [blame]
Adrià Vilanova Martínez25e12112021-08-25 13:48:06 +02001package db
2
3import (
4 "context"
5 "database/sql"
6
7 "google.golang.org/protobuf/proto"
8 "google.golang.org/protobuf/types/known/timestamppb"
9
10 pb "gomodules.avm99963.com/twpt-server/api_proto"
11)
12
13func AddKillSwitchAuditLogEntry(tx *sql.Tx, ctx context.Context, logEntry *pb.KillSwitchAuditLogEntry) error {
14 logEntry.Timestamp = timestamppb.Now()
15
16 logEntryBytes, err := proto.Marshal(logEntry)
17 if err != nil {
18 return err
19 }
20
21 if _, err := tx.ExecContext(ctx, "INSERT INTO KillSwitchAuditLog (data) VALUES (?)", logEntryBytes); err != nil {
22 return err
23 }
24
25 return nil
26}