Function edit_ticket_message

Source
pub async fn edit_ticket_message(
    __arg0: Path<(i64, i64, i64, i64)>,
    __arg1: State<AppState>,
    __arg2: Extension<AuthUser>,
    __arg3: Json<Value>,
) -> impl IntoResponse
Expand description

PUT /api/modules/{module_id}/assignments/{assignment_id}/tickets/{ticket_id}/messages/{message_id}

Update (edit) a ticket message. Only the author of the message may edit it.

§Path Parameters

  • module_id (i64): Module ID (for scoping/authorization)
  • assignment_id (i64): Assignment ID (for scoping/authorization)
  • ticket_id (i64): Ticket ID (for scoping/authorization)
  • message_id (i64): The message to update

§Authorization

  • Requires a valid bearer token
  • Caller must be the author of the message; otherwise 403 Forbidden is returned

§Request Body

{ "content": "Updated message text" }
  • content (string, required): New message content (non-empty after trimming)

§WebSocket Broadcast

On success, the server broadcasts to: ws/tickets/{ticket_id}

Event payload:

{
  "event": "message_updated",
  "payload": {
    "id": 123,
    "ticket_id": 99,
    "content": "Updated message text",
    "created_at": "2025-02-01T12:00:00Z",
    "updated_at": "2025-02-01T12:05:00Z",
    "user": null
  }
}

§Responses

  • 200 OK — Message updated
{
  "success": true,
  "message": "Message updated successfully",
  "data": {
    "id": 123,
    "ticket_id": 99,
    "content": "Updated message text",
    "created_at": "2025-02-01T12:00:00Z",
    "updated_at": "2025-02-01T12:05:00Z",
    "user": null
  }
}
  • 400 Bad Request — Missing/empty content
{ "success": false, "message": "Content is required" }
  • 403 Forbidden — Caller is not the author
{ "success": false, "message": "Forbidden" }
  • 500 Internal Server Error — Database error while updating
{ "success": false, "message": "Failed to update message" }

§Example Request

PUT /api/modules/42/assignments/7/tickets/99/messages/123
Authorization: Bearer <token>
Content-Type: application/json

{ "content": "Updated message text" }