-
Notifications
You must be signed in to change notification settings - Fork 3
✨feat: pass encrypted_e_id coop status calls #2304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import ( | |
|
|
||
| "github.com/bwmarrin/discordgo" | ||
| "github.com/mkmccarty/TokenTimeBoostBot/src/ei" | ||
| "github.com/mkmccarty/TokenTimeBoostBot/src/farmerstate" | ||
| ) | ||
|
|
||
| // HandleTrackerRefresh will call the API and update the start time and duration | ||
|
|
@@ -37,7 +38,7 @@ func HandleTrackerRefresh(s *discordgo.Session, i *discordgo.InteractionCreate) | |
| // Update the tracker with new values | ||
| t, err := getTrack(userID, name) | ||
| if err == nil { | ||
| startTime, contractDurationSeconds, err := DownloadCoopStatusTracker(t.ContractID, t.CoopID) | ||
| startTime, contractDurationSeconds, err := DownloadCoopStatusTracker(t.ContractID, t.CoopID, userID) | ||
| if err != nil { | ||
| errorStr := fmt.Sprintf("Error: %s, check your coop-id", err) | ||
| _, _ = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{ | ||
|
|
@@ -60,15 +61,16 @@ func HandleTrackerRefresh(s *discordgo.Session, i *discordgo.InteractionCreate) | |
| } | ||
|
|
||
| // DownloadCoopStatusTracker will download the coop status for a given contract and coop ID | ||
| func DownloadCoopStatusTracker(contractID string, coopID string) (time.Time, float64, error) { | ||
| func DownloadCoopStatusTracker(contractID string, coopID string, userID string) (time.Time, float64, error) { | ||
| nowTime := time.Now() | ||
|
|
||
| eiContract := ei.EggIncContractsAll[contractID] | ||
| if eiContract.ID == "" { | ||
| return time.Time{}, 0, fmt.Errorf("invalid contract ID") | ||
| } | ||
|
|
||
| coopStatus, _, _, err := ei.GetCoopStatus(contractID, coopID, "") | ||
| eiID := farmerstate.GetMiscSettingString(userID, "encrypted_ei_id") | ||
| coopStatus, _, _, err := ei.GetCoopStatus(contractID, coopID, eiID) | ||
|
Comment on lines
+64
to
+73
|
||
| if err != nil { | ||
| return time.Time{}, 0, err | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateEstimatedTime is launched in a goroutine and now calls track.DownloadCoopStatusTracker, which (after this PR) performs a farmerstate lookup to get "encrypted_ei_id". farmerstate.GetMiscSettingString can mutate shared maps (newFarmer / map init), so doing this from background goroutines increases the chance of concurrent map access panics. Safer pattern: resolve the encrypted EI ID before starting the goroutine and pass the
eeidOverridestring through (and/or update DownloadCoopStatusTracker to takeeeidOverridedirectly).