Links

Step 4. Watching the features

Step duration ~28 min

Step 4.1. Email confirmation

15:49
Set the default role not authorised for every new user (object from WebUser) — create a simple scenario:
Add two data structures.
ConfirmRequest with the following fields:
  • user_id — link to WebUser;
  • code — type of string;
  • Fields for sync result processing:
    • is_success type of boolean;
    • result_title type of string;
    • result_text type of string.
CodeRequest with the following fields:
  • user_id — link to WebUser;
  • Fields for sync result processing:
    • is_success type of boolean;
    • result_title type of string;
    • result_text type of string.
Create a new web-page Watch features, and there two conditional sections:
  • The first section visible only for users with role not confirmed — there will be two forms:
    • Form for submitting ConfirmRequest;
    • Form for submitting CodeRequest;
  • The second section visible only for users with role confirmed.
Form for CodeRequest calls the scenario for generating and sending to a user a code in sync mode. The code is saved on WebUser object.
Form for ConfirmRequest compares the code with saved one on the WebUser object. If yes, the role not confirmed is removed and the roe confirmed is added to the field role on the WebUser object.

Step 4.2. Watching the features

12:34
Create new data structure WatchRequest:
  • user_id — link to WebUser;
  • feature_id — link to features;
  • type — type of string, we store there watch or unwatch
Add to data structure Features the field users_watching_ids —type of arrayLink to WebUser
New API-endpoint and new web-page Watch features, endpoint has a filter users_watching_ids arrayContainsAny {{id}} —we pick only the features that have user's ID in users_watching_ids
Add two actions:
  • Action Watch on Upvote features web-page;
  • Action Unwatch on Watch features web-page.
Scenario for processing WatchRequest (may be either sync or regular)
Then, create new scenario with the trigger Changed to development_status and request_status fields of feature object, which sends objects form users_watching_ids to the scenario "Notify users". The latter has a parameter (context variable) feature_id
That is it! Thank you for using Directual. You can find the Open Development Roadmap app among the free templates!