ProjectLibertyLabs / social-app-template

Social Application Template that uses Gateway Services
Apache License 2.0
1 stars 4 forks source link

Implement Endpoint to Edit Post #129

Open enddynayn opened 7 months ago

enddynayn commented 7 months ago

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

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

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

Responses:

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 commented 7 months ago

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 commented 7 months ago

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