Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

NextCloud Integration #11

Open
wants to merge 33 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
be65c24
some testing
Tratori Nov 23, 2020
52b5094
packages for "debugging"
Tratori Nov 26, 2020
22af6a3
who want to debug anyway
Tratori Nov 27, 2020
a546aab
some tests and fixed some ESLint issues
DevSchmidtchen Nov 27, 2020
823df75
some tests and fixed some ESLint issues
DevSchmidtchen Nov 27, 2020
4dcdd69
some more ESLint issues
DevSchmidtchen Nov 27, 2020
04f9a33
updated packages and some testing
DevSchmidtchen Dec 1, 2020
89dc863
Merge branch 'develop' into feature/netxcloud-integration
DevSchmidtchen Dec 2, 2020
090bc56
bad implementation of needed props
Tratori Dec 4, 2020
3ea6488
Merge branch 'feature/netxcloud-integration' of https://github.com/hp…
Tratori Dec 4, 2020
c13b8ff
update capabilities
Tratori Dec 7, 2020
2e8416a
restore old webdav_root
Tratori Dec 7, 2020
e897153
add basic config
Tratori Dec 7, 2020
72ed50b
statjc responses that make sense
Tratori Dec 7, 2020
b1e55d5
change settings so no full path is returned
Tratori Dec 7, 2020
c86a57d
preliminary solution for recursive updating of timestamps
DevSchmidtchen Dec 11, 2020
51e417c
fixed timestamps on root directories
DevSchmidtchen Dec 11, 2020
07e1930
some comments
DevSchmidtchen Dec 11, 2020
d2cb8b0
Merge branch 'develop' into feature/netxcloud-integration
DevSchmidtchen Dec 16, 2020
7a618a5
updated packages
DevSchmidtchen Dec 16, 2020
c274cd3
also updating courses and should work with every WebFileSystem
DevSchmidtchen Dec 16, 2020
8e3bca4
execute new function everytime a file gets updated in any way
DevSchmidtchen Dec 16, 2020
a9e5deb
removed TODO because this is not the default behaviour in other file …
DevSchmidtchen Dec 16, 2020
034436e
updatedAt with teams
DevSchmidtchen Dec 17, 2020
939e3b5
added TODO
DevSchmidtchen Dec 17, 2020
7fc682f
lastModifiedDate on root directories
DevSchmidtchen Dec 18, 2020
1a7f917
Merge branch 'develop' into feature/netxcloud-integration
DevSchmidtchen Dec 22, 2020
c17f05d
linked schulcloud-server PR which resolves updates of parent director…
DevSchmidtchen Dec 28, 2020
f164f13
updated npm
DevSchmidtchen Dec 29, 2020
3fb1f09
remove unneeded stuff
Tratori Dec 30, 2020
22d8d61
remove xml parser
Tratori Dec 30, 2020
4042849
moving owncloud settings into own file
Tratori Dec 30, 2020
9896b5c
Merge branch 'develop' into feature/netxcloud-integration
DevSchmidtchen Dec 31, 2020
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
20 changes: 16 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import WebFileSystem from "./WebFileSystem";
import UserManager from "./UserManager";
import logger from './logger';
import {environment} from './config/globals';
import Propfind from "webdav-server/lib/server/v2/commands/Propfind";
var bodyParser = require('body-parser');
require('body-parser-xml')(bodyParser)

const userManager = new UserManager()

Expand Down Expand Up @@ -48,7 +49,7 @@ Calling GET /ocs/v2.php/apps/notifications/api/v2/notifications?format=json...
Calling GET /ocs/v2.php/core/navigation/apps?absolute=true&format=json...
*/
app.use((req, res, next) => {
logger.info('Calling ' + req.method + ' ' + req.originalUrl + '...')
logger.error('Calling ' + req.method + ' ' + req.originalUrl + '...')
next()
})

Expand Down Expand Up @@ -100,13 +101,13 @@ const capabilities = {
}
}

app.get('/ocs/v1.php/cloud/capabilities?format=json', (req, res) => {
app.get('/ocs/v1.php/cloud/capabilities', (req, res) => {
logger.info('Requesting v1 capabilities (JSON)...')
res.send(capabilities)
})

// Seems to get requested much earlier, however, nextcloud tries to get /remote.php/webdav
app.get('/ocs/v2.php/cloud/capabilities?format=json', (req, res) => {
app.get('/ocs/v2.php/cloud/capabilities', (req, res) => {
logger.info('Requesting v2 capabilities (JSON)...')
res.send(capabilities)
})
Expand All @@ -117,6 +118,17 @@ app.head('/remote.php/webdav/', (req, res, next) => {
res.send()
})

const xmlParser = bodyParser.xml()
app.propfind('/remote.php/dav/files/[email protected]/', xmlParser,(req, res, next) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this value be dynamic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup! This is some sort of WIP/Testing

console.log(req.body)
let oldUrl = req.url
let urlParts = oldUrl.split('/')
let path = urlParts.slice(5)
req.url = '/remote.php/webdav/'+ path.join('/')
logger.error(req.url)
return app._router.handle(req,res,next)
})

// root path doesn't seem to work that easily with all webdav clients, if it doesn't work simply put an empty string there
app.use(webdav.extensions.express(environment.WEBDAV_ROOT, server))

Expand Down
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
},
"dependencies": {
"axios": "^0.21.0",
"body-parser": "^1.19.0",
"body-parser-xml": "^2.0.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"mime-types": "^2.1.27",
Expand Down