Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/content-type-issue-81
Browse files Browse the repository at this point in the history
  • Loading branch information
lleadbet authored Aug 10, 2021
2 parents 4fe0b4d + bdb5d51 commit 0bba539
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/database/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/jmoiron/sqlx"
)

const currentVersion = 2
const currentVersion = 3

type migrateMap struct {
SQL string
Expand Down
14 changes: 11 additions & 3 deletions internal/database/moderation.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (q *Query) AddModerator(p UserRequestParams) error {

tx := q.DB.MustBegin()
tx.NamedExec(stmt, p)
tx.NamedExec(`INSERT INTO moderator_actions VALUES(:id, :event_type, :event_timestamp, :event_version, :broadcaster_id, :user_id)`, ma)
tx.NamedExec(`INSERT INTO moderator_actions VALUES(:id, :event_timestamp, :event_type, :event_version, :broadcaster_id, :user_id)`, ma)
return tx.Commit()
}

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

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

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

tx := q.DB.MustBegin()
tx.NamedExec(stmt, p)
tx.NamedExec(`INSERT INTO ban_events VALUES(:id, :event_type, :event_timestamp, :event_version, :broadcaster_id, :user_id, :expires_at)`, ma)
tx.NamedExec(`INSERT INTO ban_events VALUES(:id, :event_timestamp, :event_type, :event_version, :broadcaster_id, :user_id, :expires_at)`, ma)
return tx.Commit()
}

Expand Down Expand Up @@ -270,6 +270,14 @@ func (q *Query) GetModeratorEvents(p UserRequestParams) (*DBResponse, error) {
log.Print(err)
return nil, err
}
// shim for https://github.com/twitchdev/twitch-cli/issues/83
_, err = time.Parse(time.RFC3339, ma.EventTimestamp)
if err != nil {
ts := ma.EventType
ma.EventType = ma.EventTimestamp
ma.EventTimestamp = ts
}

r = append(r, ma)
}
dbr := DBResponse{
Expand Down

0 comments on commit 0bba539

Please sign in to comment.