use of com.github.jamesnetherton.zulip.client.api.message.MessageFlag in project zulip-java-client by jamesnetherton.
the class ZulipMessageIT method markTopicAsRead.
@Test
public void markTopicAsRead() throws ZulipClientException {
zulip.streams().subscribe(StreamSubscriptionRequest.of("Mark Topic As Read Stream", "Mark Topic As Read Stream")).withAuthorizationErrorsFatal(false).withHistoryPublicToSubscribers(true).withInviteOnly(false).withMessageRetention(RetentionPolicy.FOREVER).withStreamPostPolicy(StreamPostPolicy.ANY).execute();
zulip.messages().sendStreamMessage("content", "Mark Topic As Read Stream", "Test Topic").execute();
long streamId = zulip.streams().getStreamId("Mark Topic As Read Stream").execute();
zulip.messages().markTopicAsRead(streamId, "Test Topic").execute();
List<Message> messages = zulip.messages().getMessages(100, 0, Anchor.NEWEST).withNarrows(Narrow.of("stream", "Mark Topic As Read Stream")).execute();
assertFalse(messages.isEmpty());
Message message = messages.get(0);
List<MessageFlag> flags = message.getFlags();
assertFalse(flags.isEmpty());
MessageFlag flag = flags.get(0);
assertEquals(MessageFlag.READ, flag);
}
use of com.github.jamesnetherton.zulip.client.api.message.MessageFlag in project zulip-java-client by jamesnetherton.
the class ZulipMessageIT method markAsRead.
@Test
public void markAsRead() throws ZulipClientException {
zulip.streams().subscribe(StreamSubscriptionRequest.of("Mark As Read Stream", "Mark As Read Stream")).withAuthorizationErrorsFatal(false).withHistoryPublicToSubscribers(true).withInviteOnly(false).withMessageRetention(RetentionPolicy.FOREVER).withStreamPostPolicy(StreamPostPolicy.ANY).execute();
zulip.messages().sendStreamMessage("content", "Mark As Read Stream", "Test Topic").execute();
Long streamId = zulip.streams().getStreamId("Mark As Read Stream").execute();
zulip.messages().markStreamAsRead(streamId).execute();
List<Message> messages = zulip.messages().getMessages(100, 0, Anchor.NEWEST).withNarrows(Narrow.of("stream", "Mark As Read Stream")).execute();
assertFalse(messages.isEmpty());
Message message = messages.get(0);
List<MessageFlag> flags = message.getFlags();
assertFalse(flags.isEmpty());
MessageFlag flag = flags.get(0);
assertEquals(MessageFlag.READ, flag);
}
use of com.github.jamesnetherton.zulip.client.api.message.MessageFlag in project zulip-java-client by jamesnetherton.
the class ZulipMessageIT method markAllAsRead.
@Test
public void markAllAsRead() throws ZulipClientException {
zulip.streams().subscribe(StreamSubscriptionRequest.of("Mark All Read Stream 1", "Mark All Read Stream 1"), StreamSubscriptionRequest.of("Mark All Read Stream 2", "Mark All Read Stream 2"), StreamSubscriptionRequest.of("Mark All Read Stream 3", "Mark All Read Stream 3")).withAuthorizationErrorsFatal(false).withHistoryPublicToSubscribers(true).withInviteOnly(false).withMessageRetention(RetentionPolicy.FOREVER).withStreamPostPolicy(StreamPostPolicy.ANY).execute();
for (int i = 1; i <= 3; i++) {
zulip.messages().sendStreamMessage("content", "Mark All Read Stream " + i, "Test Topic").execute();
}
zulip.messages().markAllAsRead().execute();
List<Message> messages = zulip.messages().getMessages(3, 0, Anchor.NEWEST).execute();
assertEquals(3, messages.size());
for (Message message : messages) {
List<MessageFlag> flags = message.getFlags();
assertFalse(flags.isEmpty());
MessageFlag flag = flags.get(0);
assertEquals(MessageFlag.READ, flag);
}
}
Aggregations