Support User groups in permissions listing #3430
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for sharing albums with user groups in addition to individual users. The changes span multiple files to extend the existing sharing functionality, update the database model, and enhance validation and testing. Below is a summary of the most important changes:
Sharing Functionality Enhancements:
applyUpdate
andapplyOverwrite
methods inapp/Actions/Sharing/Propagate.php
to handle permissions for user groups alongside individual users. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-099be4abba0aef41c0c3e3f139f6df0d8b52fcf573d6bc2fe8b120f4be446720L52-R52)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-099be4abba0aef41c0c3e3f139f6df0d8b52fcf573d6bc2fe8b120f4be446720R62)
,[[3]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-099be4abba0aef41c0c3e3f139f6df0d8b52fcf573d6bc2fe8b120f4be446720L125-R126)
,[[4]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-099be4abba0aef41c0c3e3f139f6df0d8b52fcf573d6bc2fe8b120f4be446720R135)
)Share::do
method inapp/Actions/Sharing/Share.php
to accept bothuser_id
anduser_group_id
parameters, and added logic to load the associated user group. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-ea159f4821c75cf6a4d3b3271e6273686592607be806df7d3cbfb0719f18dbe2R20-R34)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-ea159f4821c75cf6a4d3b3271e6273686592607be806df7d3cbfb0719f18dbe2R43)
)Database Model Updates:
user_group_id
support to theAccessPermission
model, including new fillable attributes and type casting. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-1dd7e2eab43d6518186bdf310214c9587a2942a7c98054107001c05054e7422aR76)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-1dd7e2eab43d6518186bdf310214c9587a2942a7c98054107001c05054e7422aR90)
)User
model for consistent permission checks. ([app/Models/User.phpR123-R130](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-37a2d7d879a7de3f7d73b2975cd22be9f41ec10c334a0dda9ad1e869332e4ecbR123-R130)
)API and Validation Enhancements:
HasUserGroupIds
interface and trait to manage user group IDs in requests. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-05b81c40be218dbe45d50a24dd501994bbec1247a72c366620554a1b2eafde89R1-R17)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-90b1d5bd6c3b34b6b303932b9761844cea879eb038795dbcb8e532f5b20be7f2R1-R25)
)AddSharingRequest
to validateuser_group_ids
and ensure at least one user or group is specified. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-088c4204a668f60ad82325c3f0b14d9d963cf16c242f7acbbb9c938f7e55024eR19-R26)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-088c4204a668f60ad82325c3f0b14d9d963cf16c242f7acbbb9c938f7e55024eR37)
,[[3]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-088c4204a668f60ad82325c3f0b14d9d963cf16c242f7acbbb9c938f7e55024eL53-R59)
,[[4]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-088c4204a668f60ad82325c3f0b14d9d963cf16c242f7acbbb9c938f7e55024eR75-R81)
)Controller and Query Updates:
SharingController
methods to support user groups in sharing logic, includingcreate
,list
, andlistAll
. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-600f9aa425dff07d96b096d9f9dc193ebd32ebfd8b6cacd23dd944f2c53a83dfL49-R77)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-600f9aa425dff07d96b096d9f9dc193ebd32ebfd8b6cacd23dd944f2c53a83dfL95-R117)
,[[3]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-600f9aa425dff07d96b096d9f9dc193ebd32ebfd8b6cacd23dd944f2c53a83dfL111-R138)
,[[4]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-600f9aa425dff07d96b096d9f9dc193ebd32ebfd8b6cacd23dd944f2c53a83dfL137-R164)
)Test Coverage:
tests/Feature_v2/Album/SharingTest.php
to cover user group sharing scenarios. ([[1]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-a352400531c5477c8773e977ade7e2893623e8766740ca40c918b59f1963a0a7R91)
,[[2]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-a352400531c5477c8773e977ade7e2893623e8766740ca40c918b59f1963a0a7L144-R146)
,[[3]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-a352400531c5477c8773e977ade7e2893623e8766740ca40c918b59f1963a0a7L159-R160)
,[[4]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-a352400531c5477c8773e977ade7e2893623e8766740ca40c918b59f1963a0a7L173-R177)
,[[5]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-a352400531c5477c8773e977ade7e2893623e8766740ca40c918b59f1963a0a7R190)
,[[6]](https://github.com/LycheeOrg/Lychee/pull/3430/files#diff-a352400531c5477c8773e977ade7e2893623e8766740ca40c918b59f1963a0a7R203)
)