I am trying to filter out posts that were hidden by the user. streaming is simple:
StreamBuilderWrapper(
shrinkWrap: true,
stream: postRef
.orderBy('stars', descending: true)
.orderBy('timestamp', descending: true)
.snapshots(),
physics: NeverScrollableScrollPhysics(),
itemBuilder: (_, DocumentSnapshot snapshot) {
Review reviews= Review.fromJson(snapshot.data());
return posts.postId != null
? Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: Reviews(review: reviews),
)
: Container(
child: Center(
child: Text('balhblahblahb'),
),
);
},
),
trying to use firestore rules to set the read permission, where hidingUserId is an array of users, and isHiddenBy a currentUser id:
match /reviews/{review}{
allow read: if request.auth != null && !(request.auth.uid in
request.resource.data.hidingUserId)
|| request.resource.data.isHiddenBy == null ||
request.resource.data.isHiddenBy != request.auth.uid
allow delete, update, create: if request.auth != null
}
playing with rules in simulator with IDs works fine. they deny the read when the userId in one of the conditions, and allow read if userId is not in. However, when I test the app on the android device, I get the:
[Firestore]: Listen for Query(target=Query(reviews order by stars, -
timestamp, -__name__);limitType=LIMIT_TO_FIRST) failed:
Status{code=PERMISSION_DENIED, description=Missing or insufficient
permissions., cause=null}
why is the denial of permission? how to structure the rules, so it filters out the posts if the user has hidden it? thanks!