Implemented the rest of the methods except for GetKillSwitchStatus
Change-Id: Ia5b1a1c44c2e52653b9845ecc9557f525e6d41b1
diff --git a/internal/db/common.go b/internal/db/common.go
new file mode 100644
index 0000000..845db2c
--- /dev/null
+++ b/internal/db/common.go
@@ -0,0 +1,26 @@
+package db
+
+import (
+ "context"
+ "database/sql"
+
+ "google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
+
+ pb "gomodules.avm99963.com/twpt-server/api_proto"
+)
+
+func AddKillSwitchAuditLogEntry(tx *sql.Tx, ctx context.Context, logEntry *pb.KillSwitchAuditLogEntry) error {
+ logEntry.Timestamp = timestamppb.Now()
+
+ logEntryBytes, err := proto.Marshal(logEntry)
+ if err != nil {
+ return err
+ }
+
+ if _, err := tx.ExecContext(ctx, "INSERT INTO KillSwitchAuditLog (data) VALUES (?)", logEntryBytes); err != nil {
+ return err
+ }
+
+ return nil
+}