Skip to content

Commit

Permalink
Remove email from everywhere since it actually requires a user access…
Browse files Browse the repository at this point in the history
… token. Will maybe add back later if needed
  • Loading branch information
bsquidwrd committed May 3, 2024
1 parent 61d3ba3 commit 4a0ad83
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 22 deletions.
2 changes: 0 additions & 2 deletions internal/database/migrations/00002_create_twitch_user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions internal/discord_notifier_handlers/handle_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
)

Expand Down
14 changes: 3 additions & 11 deletions internal/receiver_handlers/authorization_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions internal/receiver_handlers/user_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
2 changes: 0 additions & 2 deletions pkg/models/twitch/database_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 0 additions & 1 deletion pkg/models/twitch/twitch_user_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down

0 comments on commit 4a0ad83

Please sign in to comment.