I’m working on an app that ties together different funktions of other apps and extends them in certain areas.
I’m struggling with ensuring that these dependent apps are installed and stay enabled. Is there a built in solution I haven’t found or is there a best practise? Or is my whole concept of depending on parts of other apps wrong?
To give some specifics, the apps I need for my app to work properly are deck, groupfolders, files and calendar. My app has a list of objects (let’s call them projects) that can be associated with different groups. Each of these “projects” comes with its own group folder, calendar and deck board. Each group has its dedicated group folder and deck board as well. Additionally I implement own ACLs for the groups to handle my app internal permissions for CRUD of “projects” and subobjects of them.
For calendar I use a provider so there is no hard dependecy and files is always enabled, but specialy with group folders this is another story.
Currently I have a repair step (install) that checks if these apps are enabled and throws an expection if they are not, therefore not installing my app.
And on my mappers I check if the needed app is enabled. If not I disable my app and send a notification.
Now I was thinking of how to prevent admins of disabling these apps I depend on and maybe on updates if a dependent apps are disabled because of incompatibility, disabling my app as well.
The straight forward way would be to register a Listener to the AppDisableEvent and handle things there.
But I feel like this is a lot of hacking and I’m touching areas of nextcloud I shouldn’t. There must be a better way to tell the AppManager that my app has some dependencies and disabling these dependencies breaks mine.
So is there a better way or is the correct way to kind of reinvent some stuff I’m currently reusing from other apps and have a somewhat independent app by providing my own GroupMapper and so on?
It is definately a challenge that you make your own app dependant on other apps, unless they are considered official Nextcloud Apps like Talk. A few of these apps do the same, like the LDAP write support, however that one is denpendant on the LDAP app, which is considered official Nextcloud apps.
I used groupfolders until a week ago. I was getting frustrated with Groupfolders not being updated fast enough to avoid frustration for my users, when it was disabled due to incompatability after a Nextcloud upgrade. So I created a none-personal user called “Share”. I created one folder as that user, called Shares. I then shared that one with the Admin group with full rights, and then as another admin user (any actually), I creates folders in that one and shares them with specific groups, hence essentially ending with the excact end user experience as groupfolder, except the quota thing. The benefit is that this is 100% Nextcloud server, and no app dependencies. Bonus: I discovered a boost in responsetime, making the web interface load in half the time.
Files are native to Nextcloud, and will never (SHOULD never) be unsupported.
Deck is very rarely out of sync with Nextclore server releases, and neither is calendar. I think your only real issue is the Groupfolders app.
Now in regards to keeping track of apps installed or not, then you could make an OCC part of the app aswell, that checks if apps are installed, and if not, installs them and enables them.
Writing very clearly that your app is dependant on app X, Y and Z, should also be enough.
However being dependant on more than a few things, is not the best practice.
Thanks for the reply, …
Using a dedicated admin user as owner for shared folders and calendars was my first approach.
But the quota feature and the possibility to add specific users to a group share were the main reasons for using group folders. And not wanting to reinvent stuff and having to maintain them.
Your described responsetime boost is something I was suspecting as each call comes with a lot of hooks.
I guess then, specially with your comment on groupfolders update time, the solution is to reimplement the groupfolder functions I really need and keep as close to the Nextcloud server native apps as possible. And treat all dependencies to other apps as optional.
With calendar I don’t have a big issue, as I’m only providing a DAVPlugin and have an app internal event list anyway. I was thinking of extending the calendar app sidebar for a tab that shows my special x-props, but this would only be cosmetic.
I’m using Deck a lot and haven’t had issues there and besides, this is a nice to have/ optional feature to my app. I wasn’t planning on integration more that a link to a specific board and maybe the automatic creation and sharing of a board if a “project” is created.
There is no difference in adding people to a group and then a new folder “magically” appears the the users added to that group from the one solution over the other. Both solutions relies on users being member of a group. Same code. With groupfolder: Add user to group A > Access to folder Y.
With my method: Add user to group A > access to folder Y.
I can totally relate to your struggle with cross-app dependencies in the fascinating world of app development. It’s like trying to synchronize a symphony with multiple instruments, each playing a unique tune!
Based on my experience, one elegant approach to handle this situation is to leverage the power of dependency management. Consider creating a manifest file within your app, listing the essential dependencies (deck, groupfolders, files, and calendar) along with their required versions. This way, you can ensure that your app won’t even attempt to function without the prerequisites in place. Some platforms, like Composer in PHP, allow for such dependency management.
Additionally, you might want to explore implementing a graceful degradation mechanism. Instead of throwing an exception or disabling your app, offer a user-friendly notification or a dashboard with clear instructions on how to enable the necessary dependencies. This approach keeps the user experience smooth and minimizes disruptions.
As for preventing admins from disabling these vital apps inadvertently, you can integrate a safeguard mechanism within your app settings. Provide an option to “lock” or “pin” the essential dependencies, ensuring they stay enabled and minimizing compatibility issues during updates.
I have choosen the same aproach for shared folders (i.e. create user “Share” as an admin / owner of the shared folders, create folders in its space and assign groups to every folder) due the same issues with “shared folders app”. Other benefits I see in this approach:
- such folders are manipulates as standard folders, can be renamed in user space, moved somewhere … but sill are visible in the “Shared with me” menu item. Btw I asked author for such functionality, but so far without success
- such files have predicable filesystem location if they were needed to be manipulated from outside (this was my case - I need synced/added files in them from outside and then rescan these folders)
Wotks perfectly without any issue.