Fix error path when channel is not found
This commit is contained in:
parent
e98bd8c507
commit
0249a58a36
1 changed files with 15 additions and 9 deletions
|
@ -128,17 +128,23 @@ def predicate_for_query(query: str):
|
||||||
|
|
||||||
|
|
||||||
def resolve_team(mm_api: mattermost.MMApi, query: str) -> Optional[Dict]:
|
def resolve_team(mm_api: mattermost.MMApi, query: str) -> Optional[Dict]:
|
||||||
return first(filter(
|
return first(
|
||||||
predicate_for_query(query),
|
filter(
|
||||||
mm_api.get_teams()
|
predicate_for_query(query),
|
||||||
))
|
mm_api.get_teams()
|
||||||
|
),
|
||||||
|
None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def resolve_channel(mm_api: mattermost.MMApi, team_id: str, query: str) -> Optional[Dict]:
|
def resolve_channel(mm_api: mattermost.MMApi, team_id: str, query: str) -> Optional[Dict]:
|
||||||
return first(filter(
|
return first(
|
||||||
predicate_for_query(query),
|
filter(
|
||||||
mm_api.get_team_channels(team_id)
|
predicate_for_query(query),
|
||||||
))
|
mm_api.get_team_channels(team_id)
|
||||||
|
),
|
||||||
|
None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def resolve_team_channel(mm_api: mattermost.MMApi, query: str) -> Dict:
|
def resolve_team_channel(mm_api: mattermost.MMApi, query: str) -> Dict:
|
||||||
|
@ -156,7 +162,7 @@ def resolve_team_channel(mm_api: mattermost.MMApi, query: str) -> Dict:
|
||||||
else:
|
else:
|
||||||
channel = resolve_channel(mm_api, team["id"], query_parts[1])
|
channel = resolve_channel(mm_api, team["id"], query_parts[1])
|
||||||
if not channel:
|
if not channel:
|
||||||
return NotFound("channel", query_parts[1])
|
raise NotFound("channel", query_parts[1])
|
||||||
|
|
||||||
return team, channel
|
return team, channel
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue