Skip to content

Commit

Permalink
fix(AttachmentResolver): Require either fileId or session
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- authored and backportbot-nextcloud[bot] committed Nov 29, 2023
1 parent e632d72 commit b3be90a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/services/AttachmentResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class AttachmentResolver {
this.#user = user
this.#shareToken = shareToken
this.#currentDirectory = currentDirectory
this.#documentId = fileId ?? session?.documentId
this.#documentId = fileId ?? session.documentId
this.#initAttachmentListPromise = this.#updateAttachmentList()
}

Expand Down
6 changes: 3 additions & 3 deletions src/tests/services/AttachmentResolver.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Image resolver', () => {
const shareToken = 'myShareToken'

it('is a class with one constructor argument', () => {
const resolver = new AttachmentResolver({})
const resolver = new AttachmentResolver({ fileId })
expect(resolver).toBeInstanceOf(AttachmentResolver)
})

Expand All @@ -65,7 +65,7 @@ describe('Image resolver', () => {
'https://nextcloud.com/pic.jpg',
'data:4173456789ASDF',
]
const resolver = initAttachmentResolver({ })
const resolver = initAttachmentResolver({ fileId })
for (const src of sources) {
const attachment = await resolver.resolve(src)
expect(attachment.isImage).toBe(true)
Expand All @@ -84,7 +84,7 @@ describe('Image resolver', () => {

it('handles non-native urls wia webdav', async () => {
const src = `/path/to/some image.png`
const resolver = new AttachmentResolver({ user, currentDirectory })
const resolver = new AttachmentResolver({ fileId, user, currentDirectory })
const attachment = await resolver.resolve(src)
expect(attachment.isImage).toBe(true)
expect(attachment.previewUrl).toBe('http://localhost/nc-webroot/remote.php/dav/files/user-uid/parentDir/path/to/some%20image.png')
Expand Down

0 comments on commit b3be90a

Please sign in to comment.