Skip to content

Commit 0bba539

Browse files
authored
Merge branch 'main' into bugfix/content-type-issue-81
2 parents 4fe0b4d + bdb5d51 commit 0bba539

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

internal/database/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/jmoiron/sqlx"
1111
)
1212

13-
const currentVersion = 2
13+
const currentVersion = 3
1414

1515
type migrateMap struct {
1616
SQL string

internal/database/moderation.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (q *Query) AddModerator(p UserRequestParams) error {
113113

114114
tx := q.DB.MustBegin()
115115
tx.NamedExec(stmt, p)
116-
tx.NamedExec(`INSERT INTO moderator_actions VALUES(:id, :event_type, :event_timestamp, :event_version, :broadcaster_id, :user_id)`, ma)
116+
tx.NamedExec(`INSERT INTO moderator_actions VALUES(:id, :event_timestamp, :event_type, :event_version, :broadcaster_id, :user_id)`, ma)
117117
return tx.Commit()
118118
}
119119

@@ -156,7 +156,7 @@ func (q *Query) RemoveModerator(broadcaster string, user string) error {
156156

157157
tx := q.DB.MustBegin()
158158
tx.Exec(`delete from moderators where broadcaster_id=$1 and user_id=$2`, broadcaster, user)
159-
tx.NamedExec(`INSERT INTO moderator_actions VALUES(:id, :event_type, :event_timestamp, :event_version, :broadcaster_id, :user_id)`, ma)
159+
tx.NamedExec(`INSERT INTO moderator_actions VALUES(:id, :event_timestamp, :event_type, :event_version, :broadcaster_id, :user_id)`, ma)
160160
return tx.Commit()
161161
}
162162

@@ -178,7 +178,7 @@ func (q *Query) InsertBan(p UserRequestParams) error {
178178

179179
tx := q.DB.MustBegin()
180180
tx.NamedExec(stmt, p)
181-
tx.NamedExec(`INSERT INTO ban_events VALUES(:id, :event_type, :event_timestamp, :event_version, :broadcaster_id, :user_id, :expires_at)`, ma)
181+
tx.NamedExec(`INSERT INTO ban_events VALUES(:id, :event_timestamp, :event_type, :event_version, :broadcaster_id, :user_id, :expires_at)`, ma)
182182
return tx.Commit()
183183
}
184184

@@ -270,6 +270,14 @@ func (q *Query) GetModeratorEvents(p UserRequestParams) (*DBResponse, error) {
270270
log.Print(err)
271271
return nil, err
272272
}
273+
// shim for https://github.com/twitchdev/twitch-cli/issues/83
274+
_, err = time.Parse(time.RFC3339, ma.EventTimestamp)
275+
if err != nil {
276+
ts := ma.EventType
277+
ma.EventType = ma.EventTimestamp
278+
ma.EventTimestamp = ts
279+
}
280+
273281
r = append(r, ma)
274282
}
275283
dbr := DBResponse{

0 commit comments

Comments
 (0)