There are several places where we might need to retrieve a user''s SocialProfile, but if it's their first interaction with PennyU they might not yet have a social profile, so we need to create it. The easiest way to deal with this is to just replace SocialProfile.objects.get with get_or_create_social_profile_from_slack_id. We also probably need to somehow handicap SocialProfile.objects.get so that we won't accidentally use it directly in the future. Maybe it should raise an error.
Alternatively, maybe the get_or_create_social_profile_from_slack_id pattern is a bad idea. Find something better and use that instead. get_or_create_social_profile_from_slack_id is smelly, but I feel like it might be the best alternative. Otherwise we have to make sure all our Social Profiles are created before their first interaction, which seems unlikely.
There are several places where we might need to retrieve a user''s SocialProfile, but if it's their first interaction with PennyU they might not yet have a social profile, so we need to create it. The easiest way to deal with this is to just replace
SocialProfile.objects.get
withget_or_create_social_profile_from_slack_id
. We also probably need to somehow handicapSocialProfile.objects.get
so that we won't accidentally use it directly in the future. Maybe it should raise an error.Alternatively, maybe the
get_or_create_social_profile_from_slack_id
pattern is a bad idea. Find something better and use that instead.get_or_create_social_profile_from_slack_id
is smelly, but I feel like it might be the best alternative. Otherwise we have to make sure all our Social Profiles are created before their first interaction, which seems unlikely.