stakwork / sphinx-tribes

Backend for sphinx tribes and bounties. The bounty platform pays out in bitcoin. Sign up with Sphinx Chat, complete a bounty, and earn bitcoin! Go to our website for available bounties.
https://community.sphinx.chat/bounties
33 stars 60 forks source link

Implement Webhook Endpoint and update Generated User Stories #1912

Closed humansinstitute closed 1 week ago

humansinstitute commented 4 weeks ago

Context

As part of the Hive User Story Automation feature, we need to create a webhook endpoint to receive generated user stories from the Stakwork workflow service. This ticket implements the server-side endpoint to receive and store automatically generated user stories.

The web hook will receive structured story data, process it, and update the relevant feature-stories by UUID

For context this is the flow for the User Story Generation Feature image

Design

  1. Create a new webhook
  2. Add middleware logic to unpack the data object.
  3. Iterate through and update stories use existing routes r.Post("/story", featureHandlers.CreateOrEditStory) to create new user stories for each user story received.

1. Create a new webhook

Create a webhook in sphinx-tribes/routes/features.go that will receive data from the API proposed route features/stories").

2. Add logic to unpack the data object.

Output from Stakwork workflow will be in the following format. We should verify that the featureUUID is correct and present in the database.

{
  "output": {
    "featureUUID":"featureUUID" ,
    "stories": [
      {
        "userStory": "As a developer, I want the system to ensure data privacy when processing images so that sensitive information is protected.",
        "rationale": "Directly supports the mission by ensuring secure handling of data, which is essential for user trust and compliance.",
        "order": 1
      },
      {
        "userStory": "As a developer, I want the system to be accessible to users with disabilities so that everyone can use it effectively.",
        "rationale": "Enhances the product's reach and usability, aligning with the goal of providing comprehensive developer tooling.",
        "order": 2
      },
      {
        "userStory": "As a developer, I want the system to encrypt data during transmission so that it remains secure.",
        "rationale": "Ensures secure data handling, which is critical for maintaining user trust and compliance with regulations.",
        "order": 3
      }
    ]
  }
}

This will need to be retrieved and held in a variable ready for updates.

3. 3. Iterate through and update stories

Iterative through the previous variable and update each story using the exitsting endpoints at:

r.Post("/story", featureHandlers.CreateOrEditStory).

Note only the userStory string needs to be inserted into the dataabse.

4. Test by refreshing the feature page.

On refresh new stories should now be visible on the feature page.

Assignment Criteria

Before requesting assignment:

Acceptance Criteria

Webhook Implementation:

Testing:

jordan-ae commented 4 weeks ago

@humansinstitute I Can help with this

saithsab877 commented 4 weeks ago

@humansinstitute, Please assign me?

AhsanFarooqDev commented 4 weeks ago

@humansinstitute Assign me ?

humansinstitute commented 4 weeks ago

Assignments will require connection on Sphinx V2 - Curently blocked by https://github.com/stakwork/sphinx-tribes-frontend/issues/594

humansinstitute commented 1 week ago

Bug - @elraphty

We now have the rest of this feature implemented but when we hit the web hook on Staging we get no user stories generated against the feature.

I've tried this through stakwork and manually triggering the JSON output through Postman. Using postman I can confirm I get the status OK confirmation. But when reloading the feature I never get these features displayed.

Can you investigate and see where this is falling down?

Note: Doing a manual update you can see the request to "/story" perhaps there's a formatting difference that's causing hte update to not run?

Image

Example request sent onClick of "create" {"id":109,"uuid":"csq3u84nuku53b6nni40","feature_uuid":"csldm4knuku6oosk3rng","description":"Second manual","priority":2,"created":"2024-11-13T05:54:40.18381Z","updated":"2024-11-13T05:54:40.18381Z","created_by":"03824ed4d06b4274e6659e6d52ebc9ea01c05593bfa2b573afaf9e7429908972ab","updated_by":"03824ed4d06b4274e6659e6d52ebc9ea01c05593bfa2b573afaf9e7429908972ab"}

humansinstitute commented 1 week ago

Integration bug logged for resoltion: https://github.com/stakwork/sphinx-tribes/issues/1950

humansinstitute commented 1 week ago

Closed with integration bug logged for resolution