From 4a0ad834f49da33be32162b158918aaa83c1487b Mon Sep 17 00:00:00 2001 From: bsquidwrd Date: Thu, 2 May 2024 20:46:31 -0700 Subject: [PATCH] Remove email from everywhere since it actually requires a user access token. Will maybe add back later if needed --- .../migrations/00002_create_twitch_user.sql | 2 -- .../discord_notifier_handlers/handle_events.go | 6 +++--- internal/receiver_handlers/authorization_grant.go | 14 +++----------- internal/receiver_handlers/user_update.go | 4 +--- pkg/models/twitch/database_user.go | 2 -- pkg/models/twitch/twitch_user_info.go | 1 - 6 files changed, 7 insertions(+), 22 deletions(-) diff --git a/internal/database/migrations/00002_create_twitch_user.sql b/internal/database/migrations/00002_create_twitch_user.sql index 4ad6202..9f6a881 100644 --- a/internal/database/migrations/00002_create_twitch_user.sql +++ b/internal/database/migrations/00002_create_twitch_user.sql @@ -5,8 +5,6 @@ CREATE TABLE twitch_user ( "name" varchar NOT NULL, login varchar NOT NULL, avatar_url varchar DEFAULT '' NOT NULL, - email varchar DEFAULT '' NOT NULL, - email_verified boolean DEFAULT false NOT NULL, description varchar DEFAULT '' NOT NULL, title varchar DEFAULT '' NOT NULL, "language" varchar DEFAULT '' NOT NULL, diff --git a/internal/discord_notifier_handlers/handle_events.go b/internal/discord_notifier_handlers/handle_events.go index f9cafe8..1158c2e 100644 --- a/internal/discord_notifier_handlers/handle_events.go +++ b/internal/discord_notifier_handlers/handle_events.go @@ -29,7 +29,7 @@ func handleStreamOnline(dbServices *database.DiscordNotifierService, event twitc context.Background(), ` select - id,"name",login,avatar_url,email,email_verified,description,title,"language" + id,"name",login,avatar_url,description,title,"language" ,category_id,category_name,last_online_at,last_offline_at,live from public.twitch_user where id=$1 @@ -39,8 +39,8 @@ func handleStreamOnline(dbServices *database.DiscordNotifierService, event twitc var user twitch.DatabaseUser dbUser.Scan( - &user.Id, &user.Name, &user.Login, &user.AvatarUrl, &user.Email, &user.EmailVerified, - &user.Description, &user.Title, &user.Language, &user.CategoryId, &user.CategoryName, + &user.Id, &user.Name, &user.Login, &user.AvatarUrl, &user.Description, &user.Title, + &user.Language, &user.CategoryId, &user.CategoryName, &user.LastOnlineAt, &user.LastOfflineAt, &user.Live, ) diff --git a/internal/receiver_handlers/authorization_grant.go b/internal/receiver_handlers/authorization_grant.go index 057a742..7f2a545 100644 --- a/internal/receiver_handlers/authorization_grant.go +++ b/internal/receiver_handlers/authorization_grant.go @@ -77,25 +77,17 @@ func processAuthorizationGrant(dbServices *database.ReceiverService, notificatio twitchChannel := twitchChannels.Data[0] - // Twitch docs says "verified email address" is provided in this field - emailVerified := false - if twitchUser.Email != "" { - emailVerified = true - } - // Save info to database _, err = dbServices.Database.Exec(context.Background(), ` - insert into public.twitch_user (id,"name",login,avatar_url,email,email_verified,description,title,"language",category_id,category_name) - values($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11) + insert into public.twitch_user (id,"name",login,avatar_url,description,title,"language",category_id,category_name) + values($1,$2,$3,$4,$5,$6,$7,$8,$9) on conflict (id) do update - set "name"=$2,login=$3,avatar_url=$4,email=$5,email_verified=$6,description=$7,title=$8,"language"=$9,category_id=$10,category_name=$11 + set "name"=$2,login=$3,avatar_url=$4,description=$5,title=$6,"language"=$7,category_id=$8,category_name=$9 `, twitchUser.ID, twitchUser.DisplayName, twitchUser.Login, twitchUser.ProfileImageUrl, - twitchUser.Email, - emailVerified, twitchUser.Description, twitchChannel.Title, twitchChannel.BroadcasterLanguage, diff --git a/internal/receiver_handlers/user_update.go b/internal/receiver_handlers/user_update.go index a8568d7..c0893a1 100644 --- a/internal/receiver_handlers/user_update.go +++ b/internal/receiver_handlers/user_update.go @@ -13,14 +13,12 @@ func processUserUpdate(dbServices *database.ReceiverService, notification *model _, err := dbServices.Database.Exec(context.Background(), ` update public.twitch_user - set "name"=$2,login=$3,email=$4,email_verified=$5,description=$6 + set "name"=$2,login=$3,description=$4 where id=$1 `, notification.UserID, notification.UserName, notification.UserLogin, - notification.Email, - notification.EmailVerified, notification.Description, ) diff --git a/pkg/models/twitch/database_user.go b/pkg/models/twitch/database_user.go index cbb867a..14d84b4 100644 --- a/pkg/models/twitch/database_user.go +++ b/pkg/models/twitch/database_user.go @@ -10,8 +10,6 @@ type DatabaseUser struct { Name string `json:"name"` Login string `json:"login"` AvatarUrl string `json:"avatar_url,omitempty"` - Email string `json:"email,omitempty"` - EmailVerified bool `json:"email_verified,omitempty"` Description string `json:"description,omitempty"` Title string `json:"title,omitempty"` Language string `json:"language,omitempty"` diff --git a/pkg/models/twitch/twitch_user_info.go b/pkg/models/twitch/twitch_user_info.go index f5e9b93..bab32ca 100644 --- a/pkg/models/twitch/twitch_user_info.go +++ b/pkg/models/twitch/twitch_user_info.go @@ -16,7 +16,6 @@ type User struct { Description string `json:"description"` ProfileImageUrl string `json:"profile_image_url"` OfflineImageUrl string `json:"offline_image_url"` - Email string `json:"email"` CreatedAt string `json:"created_at"` }