@@ -89,6 +89,9 @@ class PublicTrips(public_trips_pb2_grpc.PublicTripsServicer):
8989 def CreatePublicTrip (
9090 self , request : public_trips_pb2 .CreatePublicTripReq , context : CouchersContext , session : Session
9191 ) -> public_trips_pb2 .PublicTrip :
92+ if not context .get_boolean_value ("public_trips_enabled" , False ):
93+ context .abort_with_error_code (grpc .StatusCode .UNAVAILABLE , "public_trips_disabled" )
94+
9295 user = session .execute (select (User ).where (User .id == context .user_id )).scalar_one ()
9396 if not has_completed_profile (session , user ):
9497 context .abort_with_error_code (grpc .StatusCode .FAILED_PRECONDITION , "incomplete_profile_create_public_trip" )
@@ -174,6 +177,9 @@ def CreatePublicTrip(
174177 def GetPublicTrip (
175178 self , request : public_trips_pb2 .GetPublicTripReq , context : CouchersContext , session : Session
176179 ) -> public_trips_pb2 .PublicTrip :
180+ if not context .get_boolean_value ("public_trips_enabled" , False ):
181+ context .abort_with_error_code (grpc .StatusCode .UNAVAILABLE , "public_trips_disabled" )
182+
177183 trip_node_id = session .execute (
178184 select (PublicTrip .node_id ).where (PublicTrip .id == request .trip_id )
179185 ).scalar_one_or_none ()
@@ -196,6 +202,9 @@ def GetPublicTrip(
196202 def ListPublicTrips (
197203 self , request : public_trips_pb2 .ListPublicTripsReq , context : CouchersContext , session : Session
198204 ) -> public_trips_pb2 .ListPublicTripsRes :
205+ if not context .get_boolean_value ("public_trips_enabled" , False ):
206+ context .abort_with_error_code (grpc .StatusCode .UNAVAILABLE , "public_trips_disabled" )
207+
199208 page_size = min (MAX_PAGINATION_LENGTH , request .page_size or MAX_PAGINATION_LENGTH )
200209 next_page_id = int (request .page_token ) if request .page_token else 0
201210
@@ -227,6 +236,9 @@ def ListPublicTrips(
227236 def ListPublicTripsByUser (
228237 self , request : public_trips_pb2 .ListPublicTripsByUserReq , context : CouchersContext , session : Session
229238 ) -> public_trips_pb2 .ListPublicTripsByUserRes :
239+ if not context .get_boolean_value ("public_trips_enabled" , False ):
240+ context .abort_with_error_code (grpc .StatusCode .UNAVAILABLE , "public_trips_disabled" )
241+
230242 page_size = min (MAX_PAGINATION_LENGTH , request .page_size or MAX_PAGINATION_LENGTH )
231243 cursor_date , cursor_id = _parse_page_token (request .page_token )
232244 ascending = request .ascending
@@ -299,6 +311,9 @@ def ListPublicTripsByUser(
299311 def UpdatePublicTrip (
300312 self , request : public_trips_pb2 .UpdatePublicTripReq , context : CouchersContext , session : Session
301313 ) -> public_trips_pb2 .PublicTrip :
314+ if not context .get_boolean_value ("public_trips_enabled" , False ):
315+ context .abort_with_error_code (grpc .StatusCode .UNAVAILABLE , "public_trips_disabled" )
316+
302317 public_trip = session .execute (select (PublicTrip ).where (PublicTrip .id == request .trip_id )).scalar_one_or_none ()
303318
304319 if not public_trip or public_trip .user_id != context .user_id :
0 commit comments