Skip to content

Commit

Permalink
Merge pull request #8 from PerfectFit-project/285-file-sharing
Browse files Browse the repository at this point in the history
285 file sharing
  • Loading branch information
wbaccinelli authored Nov 9, 2022
2 parents 149e921 + 2853e81 commit ccd1f6b
Show file tree
Hide file tree
Showing 14 changed files with 329 additions and 52 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 15.x
- run: git config --global url."https://${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}@github.com/".insteadOf ssh://[email protected]/

- name: Add private key for goaliejs deployment
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.GOALIEJS_PRIVATE_PULL_KEY }}
- run: npm ci --prefix niceday-api
- run: npm run build --if-present --prefix niceday-api
- name: Test niceday-api
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ghcr_build_and_push_with_goaliejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: webfactory/ssh-agent@v0.5.4
- uses: webfactory/ssh-agent@v0.6.0
with:
ssh-private-key: ${{ secrets.goaliejskey }}
- name: Fetch goaliejs
Expand Down
44 changes: 42 additions & 2 deletions niceday-api/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ paths:
"200":
description: Success
x-swagger-router-controller: Messages
/files:
post:
tags:
- files
summary: Upload a file
operationId: uploadFile
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
receiver_id:
type: string
description: ID of the user we want to upload the file to
example: 38527
file_path:
type: string
description: Local path to the file we want to upload
example: C:/username/pathtofile
file:
type: string
format: binary

responses:
"200":
description: Success
x-swagger-router-controller: FileSharing
/userdata/{userId}:
get:
summary: Get user data by ID
Expand Down Expand Up @@ -107,10 +135,22 @@ paths:

components:
schemas:
FileObject:
properties:
receiver_id:
type: integer
description: ID of the user we want to upload the file to
example: 38527
file_path:
type: string
description: Local path to the file we want to upload
example: C:/username/pathtofile
description: A file to upload.

Message:
required:
- recipient_id
- text
- recipient_id
- text
type: object
properties:
recipient_id:
Expand Down
12 changes: 12 additions & 0 deletions niceday-api/controllers/FileSharing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const utils = require('../utils/writer.jsx');
const FileSharing = require('../service/FilesSharingService');

module.exports.uploadFile = function uploadFile(req, res, next, body) {
FileSharing.uploadFile(req, body)
.then((response) => {
utils.writeJson(res, response);
})
.catch((response) => {
utils.writeJson(res, response);
});
};
4 changes: 2 additions & 2 deletions niceday-api/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ describe('Tests on niceday-api server using mocked goalie-js', () => {
SenseServerEnvironment: () => ({
Alpha: undefined,
}),
SenseNetwork: jest.fn().mockImplementation(() => ({
getContact: () => new Promise((resolve) => {
Contacts: jest.fn().mockImplementation(() => ({
getConnectedContacts: () => new Promise((resolve) => {
resolve(MOCK_USER_DATA);
}),
})),
Expand Down
Loading

0 comments on commit ccd1f6b

Please sign in to comment.