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

Verify User and Send Notification Using v2 Bot #2390

Open
tobi-bams opened this issue Jan 10, 2025 · 3 comments
Open

Verify User and Send Notification Using v2 Bot #2390

tobi-bams opened this issue Jan 10, 2025 · 3 comments
Labels

Comments

@tobi-bams
Copy link
Contributor

tobi-bams commented Jan 10, 2025

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

@aliraza556
Copy link
Contributor

@humansinstitute Please assign me?

@saithsab877
Copy link
Contributor

@humansinstitute @tobi-bams assign me?

@MahtabBukhari
Copy link
Contributor

@humansinstitute please assign me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants