I'm creating a Rename-forbidden NSFileProviderUserInteractions
rule.
My goal: if sourceItem
owner is not currently logged-in user, Rename should be forbidden.
User-interaction rule in Info.plist file:
<dict>
<key>ActivationRule</key>
<string>action == "Rename" AND sourceItem.userInfo.owner != domainUserInfo.user</string>
<key>SubInteractions</key>
<array>
<dict>
<key>ActivationRule</key>
<string>TRUEPREDICATE</string>
<key>Alert</key>
<dict>
<key>LocalizedRecoveryOptions</key>
<dict>
<key>Cancel</key>
<string>OK</string>
</dict>
<key>LocalizedSubTitle</key>
<string>Only owners can rename items.</string>
<key>LocalizedTitle</key>
<string>Forbidden action</string>
<key>RecoveryOptions</key>
<dict>
<key>Continue</key>
<false/>
</dict>
</dict>
</dict>
</array>
</dict>
It smells like comparing
sourceItem.userInfo.owner != domainUserInfo.user
doesn't seem to work.
I also see an error in console:
[ERROR] User interaction is not a dictionary
If, on the other hand I hard-code the ActivationRule like:
<key>ActivationRule</key>
<string>action == "Rename" AND sourceItem.userInfo.owner != "current_user_id"</string>
then the behavior is correct (Rename is forbidden only for items not belonging to current user).
Is there a way to compare sourceItem.userInfo
and domainUserInfo
in ActivationRule predicate?
In the end the problem seemed to be elsewhere: I didn't properly set the collection owner in FileProviderEnumerator.enumerateItems()
method. Once I fixed that, things started working smoothly.
Closing as resolved.