Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing of simultaneous management of multiple subscription requests by multiple users #3

Closed
2ale2 opened this issue Dec 9, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@2ale2
Copy link
Contributor

2ale2 commented Dec 9, 2022

Using database and ConversationHandlers

Fixing idea

Of each user who requests to be signed up his username and the status associated with his application are added to a table in the database.

Please note: the database is persistent, therefore it is not removed after a script interruption.

Whenever the user has decided to subscribe, the check must be asked before the process begins, in fact a first database query about the user's username needs to be made within the main in the function wrapper.

Database checking

If the username of the user isn't in the database:

  • the script adds an entry to the DB (username and status) and the signin up process is started (launching dispatcher.py).

If the username is in the DB:

  • If he already asked Resina to be signed up ...
  • ... but the executive request has not been sent:
  • query.data = str(ISCRIZIONE),
  • the signing up process is started.
  • ... but the executive request has not been accepted from the executive group:
  • signing up process is not started,
  • user is notified.
  • If the request as been accepted from the executive group ...
  • ... but the subscription process has not been completed:
  • signing up process it resumed from the last point.

After each step the process status needs to be updated in the database.

Note: If it is not possible to create an account (Nuvola or Baserow) or insert the entry in the membership book, we have two choises:

  1. undo previous actions and mark the user as unsubscribed;
  2. terminate all the operations whatever are the outcomes and notify the new member about not completed ones.

Handlers structure

In the article describing the default behavior of an handler it is said that two users are handled separately in chronological order of request. Therefore, if a user A requests to be signed up, when a user B is already performing one of the subscription steps, it is necessary that the current function for user B is completed before the user A request is handled.
As the handlers have been structured, the termination of the function invoked by the handler via user B may cause changes on the pending request of user A, since currently handlers are added independently.

⬆️ Needs to be verified

The management method described above should permit simultaneous registration of multiple users.

@2ale2 2ale2 self-assigned this Dec 9, 2022
@2ale2 2ale2 pinned this issue Dec 9, 2022
@2ale2 2ale2 added the bug Something isn't working label Dec 9, 2022
@2ale2
Copy link
Contributor Author

2ale2 commented Dec 31, 2022

Final Outcome

Persistent database has been integrated. Furthermore, Resina can now handle multiple users at the same time thanks to a temporary created dictionary with which the bot can process the requests.

Note: see the code for details

@2ale2 2ale2 closed this as completed Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

1 participant