(self, project_id)
Add a message to project chat
        ---
        tags:
          - comments
        produces:
          - application/json
        parameters:
            - in: header
              name: Authorization
              description: Base64 encoded session token
              required: true
              type: string
              default: Token sessionTokenHere==
            - name: project_id
              in: path
              description: Project ID to attach the chat message to
              required: true
              type: integer
              default: 1
            - in: body
              name: body
              required: true
              description: JSON object for creating a new mapping license
              schema:
                  properties:
                      message:
                          type: string
                          default: This is an awesome project
        responses:
            201:
                description: Message posted successfully
            400:
                description: Invalid Request
            500:
                description: Internal Server Error
Add a message to project chat
        ---
        tags:
          - comments
        produces:
          - application/json
        parameters:
            - in: header
              name: Authorization
              description: Base64 encoded session token
              required: true
              type: string
              default: Token sessionTokenHere==
            - name: project_id
              in: path
              description: Project ID to attach the chat message to
              required: true
              type: integer
              default: 1
            - in: body
              name: body
              required: true
              description: JSON object for creating a new mapping license
              schema:
                  properties:
                      message:
                          type: string
                          default: This is an awesome project
        responses:
            201:
                description: Message posted successfully
            400:
                description: Invalid Request
            500:
                description: Internal Server Error
Add a message to project chat --- tags : - comments produces : - application / json parameters : - in : header name : Authorization description : Base64 encoded session token required : true type : string default : Token sessionTokenHere == - name : project_id in : path description : Project ID to attach the chat message to required : true type : integer default : 1 - in : body name : body required : true description : JSON object for creating a new mapping license schema : properties : message : type : string default : This is an awesome project responses : 201 : description : Message posted successfully 400 : description : Invalid Request 500 : description : Internal Server Error
def post(self, project_id):
        """
        Add a message to project chat
        ---
        tags:
          - comments
        produces:
          - application/json
        parameters:
            - in: header
              name: Authorization
              description: Base64 encoded session token
              required: true
              type: string
              default: Token sessionTokenHere==
            - name: project_id
              in: path
              description: Project ID to attach the chat message to
              required: true
              type: integer
              default: 1
            - in: body
              name: body
              required: true
              description: JSON object for creating a new mapping license
              schema:
                  properties:
                      message:
                          type: string
                          default: This is an awesome project
        responses:
            201:
                description: Message posted successfully
            400:
                description: Invalid Request
            500:
                description: Internal Server Error
        """
        authenticated_user_id = token_auth.current_user()
        if UserService.is_user_blocked(authenticated_user_id):
            return {"Error": "User is on read only mode."}, 403

        try:
            chat_dto = ChatMessageDTO(request.get_json())
            chat_dto.user_id = authenticated_user_id
            chat_dto.project_id = project_id
            chat_dto.validate()
        except DataError as e:
            current_app.logger.error(f"Error validating request: {str(e)}")
            return {"Error": "Unable to add chat message"}, 400

        try:
            project_messages = ChatService.post_message(
                chat_dto, project_id, authenticated_user_id
            )
            return project_messages.to_primitive(), 201
        except ValueError as e:
            error_msg = f"CommentsProjectsRestAPI POST: {str(e)}"
            return {"Error": error_msg}, 403
        except Exception as e:
            error_msg = f"Chat POST - unhandled error: {str(e)}"
            current_app.logger.critical(error_msg)
            return {"Error": "Unable to add chat message"}, 500
def post ( self , project_id ) : authenticated_user_id = token_auth . current_user ( ) if UserService . is_user_blocked ( authenticated_user_id ) : return { "Error" : "User is on read only mode." } , 403 try : chat_dto = ChatMessageDTO ( request . get_json ( ) ) chat_dto . user_id = authenticated_user_id chat_dto . project_id = project_id chat_dto . validate ( ) except DataError as e : current_app . logger . error ( f"Error validating request: {str(e)}" ) return { "Error" : "Unable to add chat message" } , 400 try : project_messages = ChatService . post_message ( chat_dto , project_id , authenticated_user_id ) return project_messages . to_primitive ( ) , 201 except ValueError as e : error_msg = f"CommentsProjectsRestAPI POST: {str(e)}" return { "Error" : error_msg } , 403 except Exception as e : error_msg = f"Chat POST - unhandled error: {str(e)}" current_app . logger . critical ( error_msg ) return { "Error" : "Unable to add chat message" } , 500