ChangeApi: Add method to check if a change is muted
Change-Id: Ie7e4194499a0f7401ddefaa30b1d3cb9729194a5
This commit is contained in:
@@ -3521,16 +3521,16 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
gApi.changes().id(r.getChangeId()).addReviewer(in);
|
||||
|
||||
setApiUser(user);
|
||||
assertThat(gApi.changes().id(r.getChangeId()).get().muted).isNull();
|
||||
assertThat(gApi.changes().id(r.getChangeId()).muted()).isFalse();
|
||||
gApi.changes().id(r.getChangeId()).mute(true);
|
||||
assertThat(gApi.changes().id(r.getChangeId()).get().muted).isTrue();
|
||||
assertThat(gApi.changes().id(r.getChangeId()).muted()).isTrue();
|
||||
|
||||
setApiUser(user2);
|
||||
sender.clear();
|
||||
amendChange(r.getChangeId());
|
||||
|
||||
setApiUser(user);
|
||||
assertThat(gApi.changes().id(r.getChangeId()).get().muted).isNull();
|
||||
assertThat(gApi.changes().id(r.getChangeId()).muted()).isFalse();
|
||||
|
||||
List<Message> messages = sender.getMessages();
|
||||
assertThat(messages).hasSize(1);
|
||||
|
||||
@@ -125,6 +125,13 @@ public interface ChangeApi {
|
||||
*/
|
||||
void mute(boolean mute) throws RestApiException;
|
||||
|
||||
/**
|
||||
* Check if this change is muted.
|
||||
*
|
||||
* @return true if the change is muted.
|
||||
*/
|
||||
boolean muted() throws RestApiException;
|
||||
|
||||
/**
|
||||
* Create a new change that reverts this change.
|
||||
*
|
||||
@@ -578,6 +585,11 @@ public interface ChangeApi {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean muted() throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PureRevertInfo pureRevert() throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -698,6 +698,15 @@ class ChangeApiImpl implements ChangeApi {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean muted() throws RestApiException {
|
||||
try {
|
||||
return stars.isMutedBy(change.getChange(), change.getUser().getAccountId());
|
||||
} catch (OrmException e) {
|
||||
throw asRestApiException("Cannot check if muted", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PureRevertInfo pureRevert() throws RestApiException {
|
||||
return pureRevert(null);
|
||||
|
||||
Reference in New Issue
Block a user