Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

285 file sharing #8

Merged
merged 21 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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