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

when I share the file with a remote group you cannot see the shared phrase beside shre command Icon. #93

Closed
navid-shokri opened this issue Feb 8, 2023 · 21 comments · Fixed by #94
Assignees

Comments

@navid-shokri
Copy link
Collaborator

as you can see the shells file is shared:
image

but the shared flag is not visible in the sender panel.
image

@navid-shokri
Copy link
Collaborator Author

navid-shokri commented Feb 8, 2023

I think the root cause is the result of this request that is made by the file application:

{
	"PROPFIND": {
		"scheme": "https",
		"host": "oc1.docker",
		"filename": "/remote.php/dav/files/einstein/",
		"remote": {
			"Address": "172.18.0.2:443"
		}
	}
}

@navid-shokri navid-shokri self-assigned this Feb 10, 2023
@navid-shokri
Copy link
Collaborator Author

oh, It seems too easy to solve 😄

according to these lines:
https://github.com/pondersource/core/blob/70917902ec43e7a7cd87f0dc2b149f0ab83a73c3/lib/private/Share20/Manager.php#L156

https://github.com/pondersource/core/blob/70917902ec43e7a7cd87f0dc2b149f0ab83a73c3/lib/private/Share20/Manager.php#L1263

there is an iterator that iterates all known share providers and gets all shared files from them.

these known share providers are listed there:
https://github.com/pondersource/core/blob/70917902ec43e7a7cd87f0dc2b149f0ab83a73c3/apps/dav/lib/Connector/Sabre/SharesPlugin.php#L132

so as a solution, we can just add \OCP\Share::SHARE_TYPE_REMOTE in that array 🎉

@navid-shokri navid-shokri linked a pull request Feb 13, 2023 that will close this issue
@navid-shokri
Copy link
Collaborator Author

So, I added all of the share types and the getIdentifier function in new created XShareProvider class, but there is an error related to @michielbdejong changes that should be resolved in a pair programming session.

at this line:

return $fedShareManager->getExternalManager($user->getUID());

the getExternalManager function is calling with just one argument while the signature of the function needs two arguments:

public function getExternalManager($userId = null, $ocmShareType){

@navid-shokri
Copy link
Collaborator Author

so the getAllSharedBy is implemented and all shared files in REMOTE_GROUP are fetched from the database.

@navid-shokri
Copy link
Collaborator Author

but the response to the PROPFIND request still does not show the share_type 7 for the files that are shared with remote groups.

@navid-shokri
Copy link
Collaborator Author

so I added this Line of code

$shareTypes[] = 7;

in this spot:

https://github.com/pondersource/core/blob/5a381c888ed6db83b0991b0d6509a1aa1197eca9/apps/dav/lib/Connector/Sabre/SharesPlugin.php#L215

and all the files in the backend responses are marked as shared with the remote group in the response.
but the Shared flag is still missing in the file application GUI. So, the Conclusion is: we should look into the front code for finding the reason of missed shared flag in the GUI

@navid-shokri
Copy link
Collaborator Author

@soltanireza65
can you read this thread and find out the mechanism of the shared phrase appearance in UI?

@soltanireza65
Copy link
Collaborator

have created a PL in pondersource/core#6
this fixed the sharing side and now share icon is showing

the thing that is not working is receiver is not able to accept it.
error: invalid share id

@navid-shokri
Copy link
Collaborator Author

I am suspicious about whether your solution is correct or not because I expected that this share request should be sent by Notification.php class that is located in FederatedGroup > lib > FederatedFileSharing. I will check it again to find the should We fix the problem from an upper layer or should continue with your solution

@navid-shokri
Copy link
Collaborator Author

navid-shokri commented Feb 28, 2023

so I found that the FederatedGroupShareProvider should be copied from lib\FederatedFileSharing. I did those modifications.

this comment is related to #110

@navid-shokri
Copy link
Collaborator Author

So, currently we have two problems:

1- the shared flag is not shown beside shared file name in sender side (einstein).

2- the shared file is accepted but it is not listed in receiver side (marie). and this Error is shown in side the log:

{"reqId":"wRsdZlhCjn5jgBMQToJ9","level":3,"time":"2023-02-28T16:50:09+00:00","remoteAddr":"172.18.0.6","user":"marie","app":"no app in context","method":"PROPFIND","url":"\/remote.php\/dav\/files\/marie\/","message":"Exception: {\"Exception\":\"Sabre\\\\HTTP\\\\ClientHttpException\",\"Message\":\"Unauthorized\",\"Code\":401,\"Trace\":\"
#0 \\\/var\\\/www\\\/html\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Client.php(229): Sabre\\\\HTTP\\\\Client->send()\\n
#1 \\\/var\\\/www\\\/html\\\/lib\\\/private\\\/Files\\\/Storage\\\/DAV.php(264): Sabre\\\\DAV\\\\Client->propFind()\\n
#2 \\\/var\\\/www\\\/html\\\/apps\\\/rd-sram-integration\\\/federatedgroups\\\/lib\\\/Files_Sharing\\\/External\\\/Storage.php(327): OC\\\\Files\\\\Storage\\\\DAV->propfind()\\n
#3 \\\/var\\\/www\\\/html\\\/lib\\\/private\\\/Files\\\/Storage\\\/Common.php(637): OCA\\\\FederatedGroups\\\\Files_Sharing\\\\External\\\\Storage->getPermissions()\\n
#4 \\\/var\\\/www\\\/html\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Wrapper.php(586): OC\\\\Files\\\\Storage\\\\Common->getMetaData()\\n
#5 \\\/var\\\/www\\\/html\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Availability.php(459): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Wrapper->getMetaData()\\n
#6 \\\/var\\\/www\\\/html\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Encryption.php(177): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Availability->getMetaData()\\n
#7 \\\/var\\\/www\\\/html\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Checksum.php(206): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Encryption->getMetaData()\\n
#8 \\\/var\\\/www\\\/html\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Wrapper.php(586): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Checksum->getMetaData()\\n
#9 \\\/var\\\/www\\\/html\\\/lib\\\/private\\\/Files\\\/Cache\\\/Scanner.php(115): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Wrapper->getMetaData()\\n
#10 \\\/var\\\/www\\\/html\\\/lib\\\/private\\\/Files\\\/Cache\\\/Scanner.php(150): OC\\\\Files\\\\Cache\\\\Scanner->getData()\\n
#11 \\\/var\\\/www\\\/html\\\/lib\\\/private\\\/Files\\\/View.php(1569): OC\\\\Files\\\\Cache\\\\Scanner->scanFile()\\n
#12 \\\/var\\\/www\\\/html\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/Directory.php(295): OC\\\\Files\\\\View->getDirectoryContent()\\n
#13 \\\/var\\\/www\\\/html\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/SharesPlugin.php(171): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Directory->getChildren()\\n
#14 \\\/var\\\/www\\\/html\\\/lib\\\/composer\\\/sabre\\\/event\\\/lib\\\/WildcardEmitterTrait.php(89): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\SharesPlugin->handleGetProperties()\\n
#15 \\\/var\\\/www\\\/html\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(1052): Sabre\\\\DAV\\\\Server->emit()\\n
#16 \\\/var\\\/www\\\/html\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(984): Sabre\\\\DAV\\\\Server->getPropertiesByNode()\\n
#17 \\\/var\\\/www\\\/html\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(1662): Sabre\\\\DAV\\\\Server->getPropertiesIteratorForPath()\\n
#18 \\\/var\\\/www\\\/html\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(1642): Sabre\\\\DAV\\\\Server->writeMultiStatus()\\n
#19 \\\/var\\\/www\\\/html\\\/lib\\\/composer\\\/sabre\\\/http\\\/lib\\\/Sapi.php(83): Sabre\\\\DAV\\\\Server->Sabre\\\\DAV\\\\{closure}(*** sensitive parameters replaced ***)\\n
#20 \\\/var\\\/www\\\/html\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(490): Sabre\\\\HTTP\\\\Sapi::sendResponse()\\n
#21 \\\/var\\\/www\\\/html\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(253): Sabre\\\\DAV\\\\Server->invokeMethod()\\n
#22 \\\/var\\\/www\\\/html\\\/apps\\\/dav\\\/lib\\\/Server.php(348): Sabre\\\\DAV\\\\Server->start()\\n
#23 \\\/var\\\/www\\\/html\\\/apps\\\/dav\\\/appinfo\\\/v2\\\/remote.php(31): OCA\\\\DAV\\\\Server->exec()\\n
#24 \\\/var\\\/www\\\/html\\\/remote.php(165): require_once('\\\/var\\\/www\\\/html\\\/a...')\\n
#25 {main}\",\"File\":\"\\\/var\\\/www\\\/html\\\/lib\\\/composer\\\/sabre\\\/http\\\/lib\\\/Client.php\",\"Line\":163}"}

@navid-shokri
Copy link
Collaborator Author

I finally found the code location that was responsible to marking the file as shared file.

https://github.com/pondersource/core/blob/5a381c888ed6db83b0991b0d6509a1aa1197eca9/core/js/share.js#L222

@navid-shokri
Copy link
Collaborator Author

So finally I found the code that indicate shared flag should be shown or not:

https://github.com/pondersource/core/blob/fa9f0b40e8397f64cfc9682ea1b6bed916ae9c5d/apps/files_sharing/js/share.js#L152

@navid-shokri
Copy link
Collaborator Author

navid-shokri commented Mar 2, 2023

Done and shared flag is visible beside shared file. 🏁

@navid-shokri
Copy link
Collaborator Author

I faced with another problem. when I clicked on file row and the sidebar opens the flag will be disappeared. ⚠️

@navid-shokri
Copy link
Collaborator Author

navid-shokri commented Mar 2, 2023

I found that when we click on a file there is three API calls: ℹ️

1- GET /ocs/v2.php/apps/files_sharing/api/v1/shares?format=json&path=%2Fgroup&reshares=true HTTP/1.1
Host: oc1.docker

2- GET /ocs/v2.php/apps/files_sharing/api/v1/shares?format=json&path=%2Fgroup&shared_with_me=true HTTP/1.1
Host: oc1.docker

3- PROPFIND /remote.php/dav/systemtags-relations/files/15 HTTP/1.1
Host: oc1.docker

which the first one does not return the desired information about share file with REMOTE_GROUP

@navid-shokri
Copy link
Collaborator Author

So I found the final solution:
regarding that we are inheriting the federatedgroups>FederatedGroupShareProvider from federatedFileSharing>FederatedShareProvider and this line of code is trying to call getSharesBy function the parent function is calling due to lack of function overriding in federatedgroups>FederatedGroupShareProvider class.

so we should override that function. it could be helpful.

@navid-shokri
Copy link
Collaborator Author

Done 🏁
Now the listing share recipient is shown as you can in attached picture.

image

But the name of recipient is Empty. ⚠️
It should be checked that re recipient is not stored in database or it is not fetched in query time.

@navid-shokri
Copy link
Collaborator Author

so finally I resolve this issue Completly by this commit: 🎉 🏁
pondersource/core@e5e3da4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants