sphinx-tribes icon indicating copy to clipboard operation
sphinx-tribes copied to clipboard

Verify User and Send Notification Using v2 Bot

Open tobi-bams opened this issue 11 months ago • 3 comments

Description:
This task involves verifying a user on the v2 bot before sending a notification and then logging the process and results in the database. The steps include checking the user's existence, adding the user if they are not already recognized, handling cases where a contact_key is not immediately available, sending the notification, and storing the notification details with its status in the database.

Acceptance Criteria:

  1. Verify User on the v2 Bot:

    • Call the /contact/{pubkey} endpoint to check if the user exists.

      • Expected Response:
        {
          version: number;
          my_idx: number;
          pubkey: string;
          lsp: string;
          scid: number;
          contact_key?: string;
        }
        
      • Condition:
        • If contact_key is empty, the bot does not recognize the user.
    • Add the user to the bot's known contacts by calling the /add_contact endpoint.

      • Expected Request Body
        {
         contact_info: string;
         alias?: string;
        }
        
    • Re-check the /contact/{pubkey} endpoint to verify the contact_key is now populated.

    • Handling Missing contact_key:

      • If contact_key is still empty, store the notification details in the database with a status of WAITING_KEY_EXCHANGE.
  2. Send Notification:

    • Use the /send endpoint to send the notification.

      • Request Body for Text Messages:

        {
          dest: string;       // User's pubkey
          amt_msat: 0;        // Set to 0 for text messages
          content: string;    // Notification content
          is_tribe: false;    // Set to false for direct messages
          wait: true;         // Set to true for synchronous behavior
        }
        
      • Expected Response:

        {
          status: SendOnionStatus; // "COMPLETE", "PENDING", or "FAILED"
          tag: string;
          preimage?: string;
          payment_hash?: string;
          message?: string; // Error message if status == "FAILED"
        }
        
    • Log the notification details and the response in the database, including the status (COMPLETE, PENDING, or FAILED).

  3. Database Integration:

    • Ensure the database table notifications is used for tracking. Fields should include:
      • event (e.g., bounty_assigned)
      • pubkey
      • content
      • retries
      • status
      • uuid
      • created_at

This ticket depends on this ticket

tobi-bams avatar Jan 10 '25 20:01 tobi-bams

@humansinstitute Please assign me?

aliraza556 avatar Jan 10 '25 20:01 aliraza556

@humansinstitute @tobi-bams assign me?

saithsab877 avatar Jan 10 '25 20:01 saithsab877

@humansinstitute please assign me

MahtabBukhari avatar Jan 10 '25 23:01 MahtabBukhari