Back in the OC days I had written a small app that restored important files shared by some specific âadminâ on the users accounts. I was getting the info that a user unshared a file shared by that admin by querying the database and checking some status or permissions field.
Since, the database scheme has changed and that app doesnât work. Moreover I cannot find the fields that would provide the âunsharedâ info in the new DB. Even worse, it seems like the âpost_unshareâ event does not fire when a recipient unshares a file from his account. That I could verify from the admin audit as well⊠Only if the owner unshares the file, then the event is recorder through the admin_audit.
Is there any way to know from within the database that a file has been unshared? Is there a way to catch that with a hook?
Thank you very much for the reply. May I ask why you chose to handle the events on a different file (FilesEvents.php) rather than writing the handling functions directly in the FilesHooks.php? I am trying to handle the events directly in a âHooks.phpâ and some of them do not seem to respond, i.e. the âdeleteâ event, and the âpost_unshareâ. While others do⊠I wonder if I should handle it the same way as in Nextant:
registering in an "Application.php"
catching in a "FilesHooks.php
serving in a âFilesEvents.phpâ
My code follows the logic of admin_audit app and handles the hooks directly in the âFilesHooks.phpâ.
I found this discussion when I was studying how to detect unshare by the file recipient. With some more investigation, I found that in the older versions of ownCloud there used to be signal post_unshareFromSelf emitted when the recipient unshares a file, but this was missing from ownCloud versions >= 9.0. The sharing library had been rewritten at that point, and probably the signal had been forgotten.
Hence, I made pull requests to add this signal again to ownCloud and Nextcloud. For Nextcloud, the PR is https://github.com/nextcloud/server/pull/5797 and it was merged 3 days ago. It will probably still take some time before the signal is emitted in any official release of Nextcloud.