Skip to content

Implement Endpoint to Edit Post #129

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

Open
4 tasks
enddynayn opened this issue Mar 27, 2024 · 2 comments
Open
4 tasks

Implement Endpoint to Edit Post #129

enddynayn opened this issue Mar 27, 2024 · 2 comments

Comments

@enddynayn
Copy link
Contributor

enddynayn commented Mar 27, 2024

Description
We need to implement a new PUT endpoint to allow to editing content of a specific post. This allows users to update their post without creating a new one,

Acceptance Criteria

  • Add GET /v1/content/{type}/{contentHash}
  • Ensure type and contentHash is required.
  • Ensure authentication is required.
  • Update the OpenAPI swagger documentation.

Technical Specs
Endpoint: PUT /v1/content/{type}/{contentHash}
Authentication: Required (tokenAuth)
Parameters:

  • contentHash (string, required): The hash of the post content to be edited.
  • type (string, required, "Broadcast" or "Reply"): The type of the post.

Request Body: Must match the EditPostRequest schema, requiring targetContentHash, targetAnnouncementType, and content.

Responses:

  • 200 OK: The edited post details, matching the BroadcastExtended schema.
  • 401 Unauthorized: Attempt to access the endpoint without authentication.

Open API Snippet

{
  "/v1/content/{type}/{contentHash}": {
    "put": {
      "operationId": "editContent",
      "security": [
        {
          "tokenAuth": []
        }
      ],
      "summary": "Edit the content of a specific post",
      "parameters": [
        {
          "name": "contentHash",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "type",
          "description": "Broadcast or Reply",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "requestBody": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/EditPostRequest"
            }
          }
        }
      },
      "responses": {
        "200": {
          "description": "Successful response",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BroadcastExtended"
              }
            }
          }
        },
        "401": {
          "$ref": "#/components/responses/UnauthorizedError"
        }
      }
    }
  }
}
{
"components": {
    "schemas": {
      "EditPostRequest": {
        "type": "object",
        "properties": {
          "targetContentHash": {
            "type": "string"
          },
          "targetAnnouncementType": {
            "type": "integer"
          },
          "content": {
            "type": "string"
          }
        },
        "required": [
          "content",
          "targetAnnouncementType",
          "targetContentHash"
        ]
      }
    }
  }
}
@aramikm
Copy link
Contributor

aramikm commented Mar 27, 2024

Fyi we have this endpoint already implemented inside content-publisher. Please take a look at https://github.com/AmplicaLabs/content-publishing-service/blob/main/apps/api/src/api.controller.ts#L88

@enddynayn
Copy link
Contributor Author

@aramikm you are right. This endpoint is for the Gateway-api service that will proxy the call over to Content-publisher.

wilwade referenced this issue in ProjectLibertyLabs/gateway Jul 19, 2024
* Add in redis list of endpoints watching for dsnp graph change

* give a descriptive name for clarity
wilwade referenced this issue in ProjectLibertyLabs/gateway Jul 19, 2024
* Add in redis list of endpoints watching for dsnp graph change

* give a descriptive name for clarity
wilwade referenced this issue in ProjectLibertyLabs/gateway Jul 19, 2024
@wilwade wilwade transferred this issue from ProjectLibertyLabs/gateway Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants