diff --git a/internal/database/_schema.sql b/internal/database/_schema.sql index b79aeabc..1f8d1798 100644 --- a/internal/database/_schema.sql +++ b/internal/database/_schema.sql @@ -294,9 +294,9 @@ create table stream_schedule( id text not null primary key, broadcaster_id text not null, starttime text not null, - endtime text not null, - timezone text not null, - is_vacation boolean not null default false, + endtime text not null, + timezone text not null, + is_vacation boolean not null default false, is_recurring boolean not null default false, is_canceled boolean not null default false, title text, diff --git a/internal/database/init.go b/internal/database/init.go index cdc46fcc..99ae6f35 100644 --- a/internal/database/init.go +++ b/internal/database/init.go @@ -10,7 +10,7 @@ import ( "github.com/jmoiron/sqlx" ) -const currentVersion = 6 +const currentVersion = 7 type migrateMap struct { SQL string @@ -53,6 +53,10 @@ ALTER TABLE users ADD COLUMN content_labels text not null default '';`, SQL: `DROP TABLE IF EXISTS stream_tags;`, Message: `Removing deprecated stream_tags from database.`, }, + 7: { + SQL: `ALTER TABLE stream_schedule DROP COLUMN timezone;`, + Message: `Removing deprecated stream_schedule.timezone from database`, + }, } func checkAndUpdate(db sqlx.DB) error { @@ -120,7 +124,7 @@ create table predictions ( id text not null primary key, broadcaster_id text not create table prediction_outcomes ( id text not null primary key, title text not null, users int not null default 0, channel_points int not null default 0, color text not null, prediction_id text not null, foreign key (prediction_id) references predictions(id) ); create table prediction_predictions ( prediction_id text not null, user_id text not null, amount int not null, outcome_id text not null, primary key(prediction_id, user_id), foreign key(user_id) references users(id), foreign key(prediction_id) references predictions(id), foreign key(outcome_id) references prediction_outcomes(id) ); create table clips ( id text not null primary key, broadcaster_id text not null, creator_id text not null, video_id text not null, game_id text not null, title text not null, view_count int default 0, created_at text not null, duration real not null, vod_offset int default 0, foreign key (broadcaster_id) references users(id), foreign key (creator_id) references users(id) ); -create table stream_schedule( id text not null primary key, broadcaster_id text not null, starttime text not null, endtime text not null, timezone text not null, is_vacation boolean not null default false, is_recurring boolean not null default false, is_canceled boolean not null default false, title text, category_id text, foreign key(broadcaster_id) references users(id), foreign key (category_id) references categories(id)); +create table stream_schedule( id text not null primary key, broadcaster_id text not null, starttime text not null, endtime text not null, is_vacation boolean not null default false, is_recurring boolean not null default false, is_canceled boolean not null default false, title text, category_id text, foreign key(broadcaster_id) references users(id), foreign key (category_id) references categories(id)); create table chat_settings( broadcaster_id text not null primary key, slow_mode boolean not null default 0, slow_mode_wait_time int not null default 10, follower_mode boolean not null default 0, follower_mode_duration int not null default 60, subscriber_mode boolean not null default 0, emote_mode boolean not null default 0, unique_chat_mode boolean not null default 0, non_moderator_chat_delay boolean not null default 0, non_moderator_chat_delay_duration int not null default 10, shieldmode_is_active boolean not null default 0, shieldmode_moderator_id text not null default '', shieldmode_moderator_login text not null default '', shieldmode_moderator_name text not null default '', shieldmode_last_activated text not null default '' ); create table vips ( broadcaster_id text not null, user_id text not null, created_at text not null default '', primary key (broadcaster_id, user_id), foreign key (broadcaster_id) references users(id), foreign key (user_id) references users(id) );` diff --git a/internal/database/schedule.go b/internal/database/schedule.go index 5bf9c4e9..c3516358 100644 --- a/internal/database/schedule.go +++ b/internal/database/schedule.go @@ -24,7 +24,6 @@ type ScheduleSegment struct { IsVacation bool `db:"is_vacation" json:"-"` Category *SegmentCategory `json:"category"` UserID string `db:"broadcaster_id" json:"-"` - Timezone string `db:"timezone" json:"timezone,omitempty"` CategoryID *string `db:"category_id" json:"-"` CategoryName *string `db:"category_name" dbi:"false" json:"-"` IsCanceled *bool `db:"is_canceled" json:"-"` diff --git a/internal/mock_api/endpoints/schedule/scehdule_test.go b/internal/mock_api/endpoints/schedule/schedule_test.go similarity index 98% rename from internal/mock_api/endpoints/schedule/scehdule_test.go rename to internal/mock_api/endpoints/schedule/schedule_test.go index fc3928f3..d6a74381 100644 --- a/internal/mock_api/endpoints/schedule/scehdule_test.go +++ b/internal/mock_api/endpoints/schedule/schedule_test.go @@ -133,7 +133,6 @@ func TestSegment(t *testing.T) { // post tests body := SegmentPatchAndPostBody{ Title: "hello", - Timezone: "America/Los_Angeles", StartTime: time.Now().Format(time.RFC3339), IsRecurring: &tr, Duration: "60", @@ -167,7 +166,6 @@ func TestSegment(t *testing.T) { a.Equal(401, resp.StatusCode) body.Title = "testing" - body.Timezone = "" b, _ = json.Marshal(body) req, _ = http.NewRequest(http.MethodPost, ts.URL+ScheduleSegment{}.Path(), bytes.NewBuffer(b)) q.Set("broadcaster_id", "1") @@ -176,7 +174,6 @@ func TestSegment(t *testing.T) { a.Nil(err) a.Equal(400, resp.StatusCode) - body.Timezone = "test" b, _ = json.Marshal(body) req, _ = http.NewRequest(http.MethodPost, ts.URL+ScheduleSegment{}.Path(), bytes.NewBuffer(b)) q.Set("broadcaster_id", "1") @@ -185,7 +182,6 @@ func TestSegment(t *testing.T) { a.Nil(err) a.Equal(400, resp.StatusCode) - body.Timezone = segment.Timezone body.IsRecurring = nil b, _ = json.Marshal(body) req, _ = http.NewRequest(http.MethodPost, ts.URL+ScheduleSegment{}.Path(), bytes.NewBuffer(b)) diff --git a/internal/mock_api/endpoints/schedule/segment.go b/internal/mock_api/endpoints/schedule/segment.go index 34143193..e048e617 100644 --- a/internal/mock_api/endpoints/schedule/segment.go +++ b/internal/mock_api/endpoints/schedule/segment.go @@ -39,7 +39,6 @@ type ScheduleSegment struct{} type SegmentPatchAndPostBody struct { StartTime string `json:"start_time"` - Timezone string `json:"timezone"` IsRecurring *bool `json:"is_recurring"` Duration string `json:"duration"` CategoryID *string `json:"category_id"` @@ -96,15 +95,6 @@ func (e ScheduleSegment) postSegment(w http.ResponseWriter, r *http.Request) { mock_errors.WriteBadRequest(w, "Invalid/malformed start_time provided") return } - if body.Timezone == "" { - mock_errors.WriteBadRequest(w, "Missing timezone") - return - } - _, err = time.LoadLocation(body.Timezone) - if err != nil { - mock_errors.WriteBadRequest(w, "Invalid timezone provided") - return - } var isRecurring bool @@ -139,7 +129,6 @@ func (e ScheduleSegment) postSegment(w http.ResponseWriter, r *http.Request) { CategoryID: body.CategoryID, Title: body.Title, UserID: userCtx.UserID, - Timezone: "America/Los_Angeles", IsCanceled: &f, } err = db.NewQuery(nil, 100).InsertSchedule(segment) @@ -164,7 +153,6 @@ func (e ScheduleSegment) postSegment(w http.ResponseWriter, r *http.Request) { CategoryID: body.CategoryID, Title: body.Title, UserID: userCtx.UserID, - Timezone: body.Timezone, IsCanceled: &f, } @@ -182,11 +170,6 @@ func (e ScheduleSegment) postSegment(w http.ResponseWriter, r *http.Request) { } b := dbr.Data.(database.Schedule) - // Remove timezone from JSON given in response - for i := range b.Segments { - b.Segments[i].Timezone = "" - } - if b.Vacation.StartTime == "" && b.Vacation.EndTime == "" { b.Vacation = nil } @@ -266,20 +249,6 @@ func (e ScheduleSegment) patchSegment(w http.ResponseWriter, r *http.Request) { } } - // timezone - tz, err := time.LoadLocation(segment.Timezone) - if err != nil { - mock_errors.WriteServerError(w, err.Error()) - return - } - if body.Timezone != "" { - tz, err = time.LoadLocation(body.Timezone) - if err != nil { - mock_errors.WriteBadRequest(w, "Error parsing timezone") - return - } - } - // is_canceled isCanceled := false if body.IsCanceled != nil { @@ -317,7 +286,6 @@ func (e ScheduleSegment) patchSegment(w http.ResponseWriter, r *http.Request) { StartTime: st.UTC().Format(time.RFC3339), EndTime: et.UTC().Format(time.RFC3339), IsCanceled: &isCanceled, - Timezone: tz.String(), Title: title, } @@ -334,11 +302,6 @@ func (e ScheduleSegment) patchSegment(w http.ResponseWriter, r *http.Request) { } b = dbr.Data.(database.Schedule) - // Remove timezone from JSON given in response - for i := range b.Segments { - b.Segments[i].Timezone = "" - } - if b.Vacation.StartTime == "" && b.Vacation.EndTime == "" { b.Vacation = nil } diff --git a/internal/mock_api/generate/generate.go b/internal/mock_api/generate/generate.go index c81aab71..bc6d7808 100644 --- a/internal/mock_api/generate/generate.go +++ b/internal/mock_api/generate/generate.go @@ -297,7 +297,6 @@ func generateUsers(ctx context.Context, count int) error { CategoryID: &dropsGameID, Title: "Test Title", UserID: broadcaster.ID, - Timezone: "America/Los_Angeles", IsCanceled: &f, }