diff --git a/doc/documentation.md b/doc/documentation.md index 52e4aa8..b220d6f 100644 --- a/doc/documentation.md +++ b/doc/documentation.md @@ -525,6 +525,12 @@ service cloud.firestore { function isInChatRoom() { return isSignedIn() && exists(getChatRoomUserPath(userId, chatRoomID)); } + + function isValidUpdate() { + let data = request.resource.data; + let hasPinOrMuteStatus = "pin_status" in data || "mute_status" in data; + return hasPinOrMuteStatus ? request.auth.uid == userId : true; + } function allowUserCreation() { let isUserExistsInChatRoom = exists(getChatRoomUserPath(userId, chatRoomID)); @@ -534,7 +540,7 @@ service cloud.firestore { allow delete: if (isUserInChatRoom() && checkIsUserMember(request.auth.uid)) || isInChatRoom(); allow create: if isUserExists() && isChatRoomExist() && allowUserCreation(); - allow update: if isUserInChatRoom() && checkIsUserMember(request.auth.uid); + allow update: if isUserInChatRoom() && checkIsUserMember(request.auth.uid) && isValidUpdate(); allow read: if isUserInChatRoom(); } } diff --git a/pubspec.yaml b/pubspec.yaml index a267370..08c928c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,7 +21,7 @@ environment: sdk: '>=3.4.0 <4.0.0' dependencies: - chatview_utils: ^0.0.2 + chatview_utils: ^2.0.0 cloud_firestore: ^5.6.7 firebase_storage: ^12.4.5