InquireAI / inquire

Inquire is a generalized chatbot ready to handle anything you throw at it.
https://inquire.run
MIT License
3 stars 0 forks source link

(global) allow multiple inquire accounts to be connected with the same telegram account #24

Closed ethan-stone closed 1 year ago

ethan-stone commented 1 year ago

The following would be some necessary consequences if we do allow this.

In the Connection table, the unique constraint would now have to be that a combination of connectionType, connectionUserId, and userId would have to be unique. This means the bot can no longer create connections either since it has no knowledge of the userId. It would have to be done via web.

This means that the relationship between the Inquiry table and the Connection table is now option. Since inquiries would be made with a connectionType and connectionUserId that may not exist yet.

Lastly the validation logic for creating an inquiry would of course change. Getting the total number of inquiries for the connection is still easy, just search inquiries by connectionType and connectionUserId. But, checking for a valid subscription when the connection has reached the free tier would be different. We would need to get all connections that have that connectionType and connectionUserId since there can now be multiple, and make sure at least one of the users for a connection has a valid billing status.

Lucas-Kohorst commented 1 year ago

as you mentioned on the pr not entirely sure when there would be multiple inquire accounts wanting to connect into one telegram account. The only thing I can maybe think of is that down the road someone has a personal account linked to their telegram but then also want a business account or something.

ethan-stone commented 1 year ago

Makes sense to me. I will add a check that when someone tries to connect with an account that if there is already a user attached to that connect an error is thrown