Skip to content

Commit

Permalink
Update neon_must_respond to support external API access with update…
Browse files Browse the repository at this point in the history
…d unit test (#487)

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Nov 27, 2023
1 parent 19185a1 commit e7a12e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions neon_utils/message_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,7 @@ def neon_must_respond(message: Message = None) -> bool:
else:
# Solo Private
return True
if message.context.get("client") in ("mana", "mq_api"):
# API requests should always return a response
return True
return False
5 changes: 5 additions & 0 deletions tests/message_util_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,17 @@ def test_neon_must_respond(self):
"conversation with Neon"},
{"klat_data": {
"title": "!PRIVATE:user"}})
mq_api_message = Message("", {}, {"client": "mq_api"})
mana_api_message = Message("", {}, {"client": "mana"})

self.assertFalse(neon_must_respond())
self.assertTrue(neon_must_respond(private_message_solo))
self.assertTrue(neon_must_respond(private_message_neon))
self.assertFalse(neon_must_respond(private_message_neon_plus))
self.assertFalse(neon_must_respond(public_message))
self.assertFalse(neon_must_respond(first_message))
self.assertTrue(neon_must_respond(mq_api_message))
self.assertTrue(neon_must_respond(mana_api_message))


if __name__ == '__main__':
Expand Down

0 comments on commit e7a12e3

Please sign in to comment.