hypothesis / hypothesis/h

Hidden annotations behavior is inconsistent

Open
#6,643 2 comments 0 reactions 1 assignee Claimed by @jon-betts View on GitHub
Backend bug
Dominant language
Python
Stars
3.2k
Forks
459
Avg merge
27d 1h
Merged PRs (30d)
1

Description

In this scenario, there are 3 users. A `moderator`, `user1` and `user2`. `user1` has had its annotations flagged and some hidden. There are 2 sets of screen shots to observe. One as a `moderator`, and the other as `user2`.

## As a moderator

There are 2 annotations by `user1`. The top annotation with text "test3" used to have a reply, but by another user. The annotation "test3" was flagged and hidden by a moderator. Later on, the reply by another user was deleted.

As a moderator, I can still see the annotation and I can see its hidden. This is consistent with the comments in annotation_moderation.py:
```
This hides the given annotation from anybody except its author and the
group moderators.
```

_It's worth mentioning that the exactly same behavior will happen if the reply was not deleted._

## Case 1a
- Annotation 1, deleted reply, flagged + hidden
- Annotation 2, no reply, flagged, not hidden

![Screen Shot 2021-05-12 at 12 48 48 PM](https://user-images.githubusercontent.com/3939074/118035949-cb88d600-b320-11eb-9b0c-c59affc41ec3.png)

### Behavior

**Expected behavior:** Both annotations should be returned in the API call , one set to hidden and one not.
**Actual behavior:** This is correct and what is expected.

## Case 2a
- Annotation 1, deleted reply, flagged + hidden
- Annotation 2, no reply, flagged + hidden

However, observe the second screen shot. Here we have just an annotation, again by `user1`, which never had a reply. This annotation is flagged and hidden, but when I refresh the page as a moderator, I no longer see the annotation in the response. I believe this is inconsistent with the comment in annotation_moderation.py.

![Screen Shot 2021-05-12 at 12 49 18 PM](https://user-images.githubusercontent.com/3939074/118035953-ccba0300-b320-11eb-904b-178a4818cba4.png)

### Behavior

**Expected behavior:** Both annotations should be returned in the API call with hidden set to true
**Actual behavior:** Only the top annotation is returned with hidden set to true, the other is missing.

## As `user2`

### Case 1b
- Annotation 1, deleted reply, flagged + hidden
- Annotation 2, no reply, flagged, not hidden

Next, if I'm not a moderator and a different, say user (`user2`), similar behavior occurs. In the first case, the top annotation is hidden, but we still see it. Note this annotation, had a reply, but was deleted after it was hidden. We can see this annotation comes from /h, and its values "hidden" is true, "flagged" is false and its "text" is omitted (appropriately) . I believe this is consistent with other hidden annotations that have replies, however; in this case it no longer has any replies. The fact this annotation comes back from the search in this case seems incorrect.

![Screen Shot 2021-05-12 at 2 29 18 PM](https://user-images.githubusercontent.com/3939074/118046691-8370b000-b32e-11eb-875b-62272fa2bfa3.png)

### Behavior

**Expected behavior:** The top annotation (Annotation 1) should not be returned in the API search call
**Actual behavior:** Both annotations are returned

## Case 2b
- Annotation 1, deleted reply, flagged + hidden
- Annotation 2, no reply, flagged + hidden

In this second screen shot, The last annotation was hidden by the moderator, and we can clearly see that the annotation is hidden from `user2` as expected. This annotation never had any replies.

![Screen Shot 2021-05-12 at 2 26 27 PM](https://user-images.githubusercontent.com/3939074/118046697-87043700-b32e-11eb-9cf4-fd146171dc08.png)

### Behavior

**Expected behavior:** No annotations should return in the API search call.
**Actual behavior:** The top annotation is returned

Relates to https://github.com/hypothesis/support/issues/193

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.