There is a page to view the content of the document, which displays edit buttons if the logged-in user is the content creator (Figure 1) and does not display edit buttons if he or she is not the content owner (Figure 2)
So the client app needs to know the permissions of the document, and I see that there is a $permission property in the document object to indicate the document's permissions (Figure 3)
Currently I'm parsing the $permission string to learn the document permissions (the role and id), However, I think it might be better to make this feature in the sdk.
I think it would be useful if the document object's permission provided the role and id, like:
This is the code that I use to find the id of the user who has the permission to delete documents. Just showing ideas, not coding suggestions.
...
final deletePattern = RegExp(r'delete\((.*?)\)');
final userPattern = RegExp(r'(?<=\("\s*)(.*?)(?=\s*"\))');
String? deletionUserId;
if (document.$permissions.singleWhere(
(permission) {
if ((permission as String?) case final permissionString?) {
return deletePattern.hasMatch(permissionString);
} else {
return false;
}
},
)
case final String? deletePermission when deletePermission != null) {
final user = userPattern.firstMatch(deletePermission)?.group(0)?.split(":");
if (user != null && user.length == 2) {
if (user[0] == "user") {
deletionUserId = user[1];
}
}
}
ownerUserId = deletionUserId;
...
👀 Have you spent some time to check if this issue has been raised before?
🔖 Feature description
There is a page to view the content of the document, which displays edit buttons if the logged-in user is the content creator (Figure 1) and does not display edit buttons if he or she is not the content owner (Figure 2)
So the client app needs to know the permissions of the document, and I see that there is a $permission property in the document object to indicate the document's permissions (Figure 3)
Currently I'm parsing the $permission string to learn the document permissions (the role and id), However, I think it might be better to make this feature in the sdk.
I think it would be useful if the document object's permission provided the role and id, like:
🎤 Pitch
This is the code that I use to find the id of the user who has the permission to delete documents. Just showing ideas, not coding suggestions.
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?