@@ -442,16 +443,30 @@ func (s *ApiServer) LinkGoogle(ctx context.Context, in *api.AccountGoogle) (*emp
returnnil,status.Error(codes.Unauthenticated,"Could not authenticate Google profile.")
}
displayName:=googleProfile.Name
iflen(displayName)>255{
// Ignore the name in case it is longer than db can store
s.logger.Warn("Skipping updating display_name: value received from Google longer than max length of 255 chars.",zap.String("display_name",displayName))
displayName=""
}
avatarUrl:=googleProfile.Picture
iflen(avatarUrl)>512||avatarUrl==""{
// Ignore the url in case it is longer than db can store
s.logger.Warn("Skipping updating avatar_url: value received from Google longer than max length of 512 chars.",zap.String("avatar_url",avatarUrl))
// At least one difference found, update the DB to reflect changed values
if_,err=db.ExecContext(ctx,"UPDATE users SET display_name = $1, avatar_url = $2, update_time = now() WHERE id = $3",displayName,avatarUrl,dbUserID);err!=nil{
logger.Error("Error in updating google profile details",zap.Error(err),zap.String("googleId",googleProfile.Sub),zap.String("display_name",googleProfile.Name),zap.String("display_name",googleProfile.Picture))
// Do no return error. Failure to update the display_name / avatar_url should not
// interrupt the execution. Ignore the result and the error, just log the error.