@@ -863,7 +863,9 @@ def mutate(self, info, fcm_token, days_of_week, gyms, capacity_percent):
863863 for day in validated_workout_days :
864864 topic_name = f"{ gym } _{ day } _{ capacity_percent } "
865865 try :
866- messaging .subscribe_to_topic (fcm_token , topic_name )
866+ response = messaging .subscribe_to_topic (fcm_token , topic_name )
867+ if response .success_count == 0 :
868+ raise Exception (response .errors [0 ].reason )
867869 except Exception as error :
868870 raise GraphQLError (f"Error subscribing to topic for { topic_name } : { error } " )
869871
@@ -916,7 +918,9 @@ def mutate(self, info, reminder_id, gyms, days_of_week, capacity_percent):
916918
917919 for topic in topics :
918920 try :
919- messaging .unsubscribe_from_topic (reminder .fcm_token , topic )
921+ response = messaging .unsubscribe_from_topic (reminder .fcm_token , topic )
922+ if response .success_count == 0 :
923+ raise Exception (response .errors [0 ].reason )
920924 except Exception as error :
921925 raise GraphQLError (f"Error subscribing to topic: { error } " )
922926
@@ -925,7 +929,9 @@ def mutate(self, info, reminder_id, gyms, days_of_week, capacity_percent):
925929
926930 for topic in topics :
927931 try :
928- messaging .subscribe_to_topic (reminder .fcm_token , topic )
932+ response = messaging .subscribe_to_topic (reminder .fcm_token , topic )
933+ if response .success_count == 0 :
934+ raise Exception (response .errors [0 ].reason )
929935 except Exception as error :
930936 raise GraphQLError (f"Error subscribing to topic: { error } " )
931937
@@ -954,7 +960,9 @@ def mutate(self, info, reminder_id):
954960
955961 for topic in topics :
956962 try :
957- messaging .unsubscribe_from_topic (reminder .fcm_token , topic )
963+ response = messaging .unsubscribe_from_topic (reminder .fcm_token , topic )
964+ if response .success_count == 0 :
965+ raise Exception (response .errors [0 ].reason )
958966 except Exception as error :
959967 raise GraphQLError (f"Error unsubscribing from topic { topic } : { error } " )
960968
0 commit comments