fix search by channel for invalid channel
This commit is contained in:
parent
21e023f0db
commit
c3e426c491
2 changed files with 4 additions and 4 deletions
|
@ -236,11 +236,10 @@ class SearchIndex:
|
|||
|
||||
async def search(self, **kwargs):
|
||||
if 'channel' in kwargs:
|
||||
results, _, _ = await self.resolve(kwargs.pop('channel'))
|
||||
if not results or not isinstance(results, Iterable):
|
||||
channel_id = await self.resolve_url(kwargs.pop('channel'))
|
||||
if not channel_id or not isinstance(channel_id, str):
|
||||
return [], 0, 0
|
||||
result = results[0] if results else None
|
||||
kwargs['channel_id'] = result['claim_id']
|
||||
kwargs['channel_id'] = channel_id
|
||||
try:
|
||||
result = await self.search_client.search(
|
||||
expand_query(**kwargs), index=self.index, track_total_hits=200
|
||||
|
|
|
@ -150,6 +150,7 @@ class ClaimSearchCommand(ClaimTestCase):
|
|||
claims = [three, two, signed]
|
||||
await self.assertFindsClaims(claims, channel_ids=[self.channel_id])
|
||||
await self.assertFindsClaims(claims, channel=f"@abc#{self.channel_id}")
|
||||
await self.assertFindsClaims([], channel=f"@inexistent")
|
||||
await self.assertFindsClaims([three, two, signed2, signed], channel_ids=[channel_id2, self.channel_id])
|
||||
await self.channel_abandon(claim_id=self.channel_id)
|
||||
await self.assertFindsClaims([], channel=f"@abc#{self.channel_id}", valid_channel_signature=True)
|
||||
|
|
Loading…
Reference in a new issue