@@ -196,61 +196,6 @@ def paginate_list(items: List, page: Optional[int], page_size: Optional[int]):
196196 }
197197
198198
199- def fix_kwargs_for_hub (** kwargs ):
200- repeated_fields = {"media_type" , "stream_type" , "claim_type" }
201- value_fields = {"tx_nout" , "has_source" , "is_signature_valid" }
202- opcodes = {'=' : 0 , '<=' : 1 , '>=' : 2 , '<' : 3 , '>' : 4 }
203- for key , value in list (kwargs .items ()):
204- if value in (None , [], False ):
205- kwargs .pop (key )
206- continue
207- if key in REPLACEMENTS :
208- kwargs [REPLACEMENTS [key ]] = kwargs .pop (key )
209- key = REPLACEMENTS [key ]
210-
211- if key == "normalized_name" :
212- kwargs [key ] = normalize_name (value )
213- if key == "limit_claims_per_channel" :
214- value = kwargs .pop ("limit_claims_per_channel" ) or 0
215- if value > 0 :
216- kwargs ["limit_claims_per_channel" ] = value
217- elif key == "invalid_channel_signature" :
218- kwargs ["is_signature_valid" ] = {"value" : not kwargs .pop ("invalid_channel_signature" )}
219- elif key == "has_no_source" :
220- kwargs ["has_source" ] = {"value" : not kwargs .pop ("has_no_source" )}
221- elif key in value_fields :
222- kwargs [key ] = {"value" : value } if not isinstance (value , dict ) else value
223- elif key in repeated_fields and isinstance (value , str ):
224- kwargs [key ] = [value ]
225- elif key in ("claim_id" , "channel_id" ):
226- kwargs [key ] = {"invert" : False , "value" : [kwargs [key ]]}
227- elif key in ("claim_ids" , "channel_ids" ):
228- kwargs [key [:- 1 ]] = {"invert" : False , "value" : kwargs .pop (key )}
229- elif key == "not_channel_ids" :
230- kwargs ["channel_id" ] = {"invert" : True , "value" : kwargs .pop ("not_channel_ids" )}
231- elif key in MY_RANGE_FIELDS :
232- constraints = []
233- for val in value if isinstance (value , list ) else [value ]:
234- operator = '='
235- if isinstance (val , str ) and val [0 ] in opcodes :
236- operator_length = 2 if val [:2 ] in opcodes else 1
237- operator , val = val [:operator_length ], val [operator_length :]
238- val = [int (val if key != 'fee_amount' else Decimal (val )* 1000 )]
239- constraints .append ({"op" : opcodes [operator ], "value" : val })
240- kwargs [key ] = constraints
241- elif key == 'order_by' : # TODO: remove this after removing support for old trending args from the api
242- value = value if isinstance (value , list ) else [value ]
243- new_value = []
244- for new_v in value :
245- migrated = new_v if new_v not in (
246- 'trending_mixed' , 'trending_local' , 'trending_global' , 'trending_group'
247- ) else 'trending_score'
248- if migrated not in new_value :
249- new_value .append (migrated )
250- kwargs [key ] = new_value
251- return kwargs
252-
253-
254199DHT_HAS_CONTACTS = "dht_has_contacts"
255200
256201
@@ -2673,42 +2618,27 @@ async def jsonrpc_claim_search(self, **kwargs):
26732618
26742619 Returns: {Paginated[Output]}
26752620 """
2676- if self .ledger .config .get ('use_go_hub' ):
2677- host = self .ledger .network .client .server [0 ]
2678- port = "50051"
2679- kwargs ['new_sdk_server' ] = f"{ host } :{ port } "
2680- if kwargs .get ("channel" ):
2681- channel = kwargs .pop ("channel" )
2682- channel_obj = (await self .jsonrpc_resolve (channel ))[channel ]
2683- if isinstance (channel_obj , dict ):
2684- # This happens when the channel doesn't exist
2685- kwargs ["channel_id" ] = ""
2686- else :
2687- kwargs ["channel_id" ] = channel_obj .claim_id
2688- kwargs = fix_kwargs_for_hub (** kwargs )
2689- else :
2690- # Don't do this if using the hub server, it screws everything up
2691- if "claim_ids" in kwargs and not kwargs ["claim_ids" ]:
2692- kwargs .pop ("claim_ids" )
2693- if {'claim_id' , 'claim_ids' }.issubset (kwargs ):
2694- raise ConflictingInputValueError ('claim_id' , 'claim_ids' )
2695- if kwargs .pop ('valid_channel_signature' , False ):
2696- kwargs ['signature_valid' ] = 1
2697- if kwargs .pop ('invalid_channel_signature' , False ):
2698- kwargs ['signature_valid' ] = 0
2699- if 'has_no_source' in kwargs :
2700- kwargs ['has_source' ] = not kwargs .pop ('has_no_source' )
2701- if 'order_by' in kwargs : # TODO: remove this after removing support for old trending args from the api
2702- value = kwargs .pop ('order_by' )
2703- value = value if isinstance (value , list ) else [value ]
2704- new_value = []
2705- for new_v in value :
2706- migrated = new_v if new_v not in (
2707- 'trending_mixed' , 'trending_local' , 'trending_global' , 'trending_group'
2708- ) else 'trending_score'
2709- if migrated not in new_value :
2710- new_value .append (migrated )
2711- kwargs ['order_by' ] = new_value
2621+ if "claim_ids" in kwargs and not kwargs ["claim_ids" ]:
2622+ kwargs .pop ("claim_ids" )
2623+ if {'claim_id' , 'claim_ids' }.issubset (kwargs ):
2624+ raise ConflictingInputValueError ('claim_id' , 'claim_ids' )
2625+ if kwargs .pop ('valid_channel_signature' , False ):
2626+ kwargs ['signature_valid' ] = 1
2627+ if kwargs .pop ('invalid_channel_signature' , False ):
2628+ kwargs ['signature_valid' ] = 0
2629+ if 'has_no_source' in kwargs :
2630+ kwargs ['has_source' ] = not kwargs .pop ('has_no_source' )
2631+ if 'order_by' in kwargs : # TODO: remove this after removing support for old trending args from the api
2632+ value = kwargs .pop ('order_by' )
2633+ value = value if isinstance (value , list ) else [value ]
2634+ new_value = []
2635+ for new_v in value :
2636+ migrated = new_v if new_v not in (
2637+ 'trending_mixed' , 'trending_local' , 'trending_global' , 'trending_group'
2638+ ) else 'trending_score'
2639+ if migrated not in new_value :
2640+ new_value .append (migrated )
2641+ kwargs ['order_by' ] = new_value
27122642 page_num , page_size = abs (kwargs .pop ('page' , 1 )), min (abs (kwargs .pop ('page_size' , DEFAULT_PAGE_SIZE )), 50 )
27132643 wallet = self .wallet_manager .get_wallet_or_default (kwargs .pop ('wallet_id' , None ))
27142644 kwargs .update ({'offset' : page_size * (page_num - 1 ), 'limit' : page_size })
0 commit comments