-
Notifications
You must be signed in to change notification settings - Fork 3
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
Staging #69
Conversation
Ent Schema
Data abstraction
birthday abstractions
Slash command
Scheduled event
Sophduke patch 1
Birthday Feature
Patch to Birthday Command
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.
Suggestion to prevent issue: Prevent change while its your birthday or limit number of changes allowed
entRemoveBirthdays, err := data.Birthday.GetBirthdays(yesterday.Day(), int(yesterday.Month()), internalSpan.Context()) | ||
if err != nil { | ||
logging.Error(s, "failed to get yesterday's birthdays", nil, span, logrus.Fields{"error": err}) | ||
return | ||
} | ||
|
||
// Remove yesterday's birthdays | ||
for _, entRemoveBirthday := range entRemoveBirthdays { | ||
err = removeBirthday(s, entRemoveBirthday.Edges.User.ID, internalSpan.Context()) | ||
if err != nil { | ||
logging.Error(s, "failed to remove birthday for "+helpers.AtUser(entRemoveBirthday.Edges.User.ID), nil, span, logrus.Fields{"error": err}) | ||
return | ||
} | ||
} |
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.
Edge/Exploit Case: I move my birthday on my birthday. I wouldn't come up here
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.
This is the scheduled task that adds and removes birthdays at midnight.
This edge case is covered in the snippets commented below
now := time.Now().In(tz) | ||
if month == int(now.Month()) && day == int(now.Day()) { | ||
// respond to user that birthday cannot be today | ||
|
||
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ | ||
Type: discordgo.InteractionResponseChannelMessageWithSource, | ||
Data: &discordgo.InteractionResponseData{ | ||
Content: "You cannot set your birthday to be today", | ||
Flags: discordgo.MessageFlagsEphemeral, | ||
}, | ||
}) | ||
if err != nil { | ||
logging.Error(s, "encounted error when responding to user", i.Member.User, span, logrus.Fields{"err": err.Error()}) | ||
} | ||
|
||
return | ||
} |
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.
Birthday Edit or Add on Birthday Edge Case
now := time.Now().In(tx) | ||
if int(entBirthday.Month) == int(now.Month()) && int(entBirthday.Day) == int(now.Day()) { | ||
// respond to user that birthday cannot be today | ||
|
||
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ | ||
Type: discordgo.InteractionResponseChannelMessageWithSource, | ||
Data: &discordgo.InteractionResponseData{ | ||
Content: "You cannot remove your birthday today", | ||
Flags: discordgo.MessageFlagsEphemeral, | ||
}, | ||
}) | ||
if err != nil { | ||
logging.Error(s, "encounted error when responding to user", i.Member.User, span, logrus.Fields{"err": err.Error()}) | ||
} | ||
|
||
return | ||
} |
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.
Birthday Delete on Birthday Edge Case
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.
No description provided.