Skip to content

Show signature status on files app #4971

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

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

AntDavidLima
Copy link

@AntDavidLima AntDavidLima commented May 19, 2025

Pull Request Description

This pull request adds an icon to the right of the files, in the files app, showing the file signature status on the original and the signed files. The original will have the status 'Original file signed elsewhere' and the signed file will have the status 'Partially signed' and 'Signed', depending on the signing progress.

Before: After:
before after

To test the feature, after checking out to the pull request:

  • upload a PDF file to Nextcloud using the files app;
  • request the signature from two different users;
  • sign the file with one of the requested users;
  • the original file will show a green sign icon, with the text 'original file' when hovering over it;
  • the signed file will show a yellow ½ icon, with the text 'partially signed' when hovering over it;
  • now sign the file with the second requested user;
  • the signed file will show a blue sign icon, with the text 'signed' when hovering over it.

Related Issue

Issue Number: #4160

Pull Request Type

  • Feature

Pull request checklist

  • Did you explain or provide a way of how can we test your code ?
  • If your pull request is related to frontend modifications provide a print of before and after screen
  • Did you provide a general summary of your changes ?
  • Try to limit your pull request to one type, submit multiple pull requests if needed
  • I implemented tests that cover my contribution

Only show signature icon on files of pdf type and if the LibreSign
certificate is ok

Signed-off-by: David Lima <[email protected]>
Get file status by nodeId

Signed-off-by: David Lima <[email protected]>
@github-project-automation github-project-automation bot moved this to 0. Needs triage in Roadmap May 19, 2025
Copy link

welcome bot commented May 19, 2025

Thanks for opening your first pull request in this repository! ✌️

@AntDavidLima AntDavidLima marked this pull request as draft May 19, 2025 14:22
Change code style, add copyright text and fix end-point response type to
pass previously failing tasks

Signed-off-by: David Lima <[email protected]>
… ids

Change the end-point filter parameter from nodeId to nodeIds, allowing
the filtering by multiple node ids

Signed-off-by: David Lima <[email protected]>
Update front end calls to /list/list end-point so it passes node ids
filter as an array

Signed-off-by: David Lima <[email protected]>
Change the status icon and label based on the response from the API

Signed-off-by: David Lima <[email protected]>
Add the property signedNodeId to the /file/list end-point to show an
icon on the original and signed file, according to the signing status

Signed-off-by: David Lima <[email protected]>
@@ -236,7 +236,7 @@ private function validate(?string $type = null, $identifier = null): DataRespons
* List account files that need to be approved
*
* @param string|null $signer_uuid Signer UUID
* @param string|null $nodeId The nodeId (also called fileId). Is the id of a file at Nextcloud
* @param list<string>|null $nodeIds The list of nodeIds (also called fileIds). It's the ids of files at Nextcloud
Copy link
Member

Choose a reason for hiding this comment

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

After implement, change or delete a controller, you should run the follow command at libresign folder inside the container to update the documentation:

composer openapi

You also need to check the other places that this endpoint is used with this argument. Tip: search at folder libresign/src by file/list. Have a place that use the argument nodeId.

Copy link
Author

@AntDavidLima AntDavidLima May 22, 2025

Choose a reason for hiding this comment

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

You also need to check the other places that this endpoint is used with this argument.

The only place I found it been used was on the src/store/files.js, and this is already adapted on this PR.

Copy link
Member

Choose a reason for hiding this comment

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

The endpoit to 'file/list' is used only at src/store/files.js by the method getAllFiles and this method using the filter nodeId is used only at this file by method flushSelectedFile by this way:

const files = await this.getAllFiles({
	nodeId: this.selectedNodeId,
})

Changing nodeId to nodeIds and the parameter to an array will solve.

$qb->andWhere(
$qb->expr()->eq('f.node_id', $qb->createNamedParameter($filter['nodeId'], IQueryBuilder::PARAM_INT))
$qb->expr()->in('f.node_id', $qb->createNamedParameter($filter['nodeIds'], IQueryBuilder::PARAM_STR_ARRAY))
Copy link
Member

Choose a reason for hiding this comment

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

You will need to ad OR at this point to also search by signed_node_id.

Copy link
Author

Choose a reason for hiding this comment

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

I think in the way I implemented, this will not be necessary, since I already check at the front-end if the returned row have a signedNodeId, and if it have it, show it status.
Also, when I begin implementing, I didn't know how many places used this end-point, so I avoided change it so much.

Copy link
Member

@vitormattos vitormattos May 22, 2025

Choose a reason for hiding this comment

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

I think in the way I implemented, this will not be necessary, since I already check at the front-end if the returned row have a signedNodeId, and if it have it, show it status.

Check this scenario:

When go to app Files
I put a PDF file called "file.pdf" inside folder A
I send a herself signature request
I sign the file
Then I will see the file "file.signed.pdf" inside folder A
When I move the file "file.signed.pdf" to folder B
And I go to folder B
Then I need to see the LibreSign status at file "file.signed.pdf"

I didn't reproduced this scenario but I think that don't will work with the current implementation.

Only an information about what's nodeId: The nodeId at Nextcloud context could be a directory or a file that was indexed and was added to table filecache to we have a good performance when fetch the content of a folder because we don't will have a big IO to list the content. This is the most common implementation. To have more performance, also is possible implement Redis and prevent a lot of hits at database. When we move a file from directory A to B, the nodeId don't will be changed, only will be changed the data of this file at the database.

Also, when I begin implementing, I didn't know how many places used this end-point, so I avoided change it so much.

Don't worry, we have unit and integration tests in the backend and they already broke 😅.

Copy link
Author

Choose a reason for hiding this comment

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

So, when I saw this comment I really thought this flux would break, but I just tested it and it just worked in this scenario described by you and in other scenarios I've tried. Not sure though why this worked. I've thought that it was some kinda of caching that made it work anyway, but tried a different browser and it still worked.

Should I made this change even with it working this way?

@github-project-automation github-project-automation bot moved this from 0. Needs triage to 1. to do in Roadmap May 22, 2025
Alter the Copyright text year to the file creation year

Signed-off-by: David Lima <[email protected]>
Send function parameter already with the right name, so a useless if
condition is avoided

Signed-off-by: David Lima <[email protected]>
@vitormattos vitormattos marked this pull request as ready for review May 23, 2025 19:17
@vitormattos vitormattos marked this pull request as draft May 23, 2025 19:17
Add column signed_node_id to getFiesAssociatedFilesWithMeQueryBuilder
method query group by

Signed-off-by: David Lima <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 1. to do
Development

Successfully merging this pull request may close these issues.

2 participants