Key Information

Register
Submit
The challenge is finished.

Challenge Overview

Challenge Objectives

  • Develop a NodeJS API to support file attachments while posting messages

 

Project Background

  • Topcoder message microservice is responsible for messaging in our Connect app - creating/editing topics and posts

  • In this challenge we want to revamp support for post attachments

  • Future challenges will update frontend, add support for email attachments, inline attachments, etc

 

Technology Stack

  • NodeJS

  • Postgres

  • Elasticsearch

  • S3

  • Postman

 

Code access

Latest code is available at our project repo, develop branch.

 

Individual requirements

  1. Update create attachment logic
    Current create attachment endpoint requires an existing topic to create an attachment - this is good as it doesn’t allow uploading a file unless you have access to the topic, but also has a drawback that a post attachment can’t be uploaded in parallel to writing a topic/post. The updated create attachment endpoint will allow creating attachments to any logged in user and will create post_attachment record in the database with post_id being null. The file will not be uploaded to the message service, but to an s3 bucket and the create attachment endpoint will only get the uploaded file info - file name, bucket name/path and content type. Endpoint only has to copy the uploaded file from the public bucket  to a configurable bucket - same operation as done in our project-service

  2. Update create topic/post endpoint
    Add a new parameter to the create and update topic and post endpoints called “attachmentIds” that will be used to update referenced attachments with the created postId. Once the post is created, update all post_attachments records with ids in attachmentIds to have the new postId, but don’t allow changing postId of existing attachments. Second update for each of these endpoints is to update elasticsearch index with details of the post attachments

  3. Update data models and get/list endpoints
    Update post model to reference post_attachments model (one to many) and update get and list topics and posts endpoints to return the post attachments. Six endpoints are in scope here: posts (get and list), topics(list, listDb, get, getDb). Response should not contain the following attachment record fields: 'deletedAt', 'deletedBy', 'url'. URL is the internal s3 link, but the caller needs a signed link to access the file (should call the get attachment endpoint to get the signed link, see the next section). This change will include updating adapter service.

  4. Update get attachment endpoint
    Current get attachment endpoint requires the caller to pass too many parameters: postId, attachmentId, referenceId. We’ll remove the referenceId requirement and do the following: use the postId to get the topic from the db and use topic.referenceId to check user permissions. Everything else in this endpoint should remain the same

  5. Update delete attachment endpoint
    Same ‘referenceId’ change should be implemented in this endpoint.

  6. Create a script to clean up unused attachments

Since we are allowing file upload without an existing post, we need to clean up the files where user uploads an attachment but never creates a post. We need a script that will select all post attachments with postId=null and createdBy older than a configurable time (24hrs by default). It should hard delete all such attachments. Script will be run manually for now.

 

General for all requirements

Unit tests are required for all new or updated endpoints. Postman collection and swagger should be updated. Note that all calls to topcoder services should be mocked in this challenge as the APIs are not available at the moment. See the forums for API response formats for each required endpoint.

 

What To Submit

Updated code

Postman

Swagger

Readme



Final Submission Guidelines

Updated code

Postman

Swagger

Readme

ELIGIBLE EVENTS:

Topcoder Open 2019

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30088008