use of com.symphony.api.model.V4MessageSent in project spring-bot by finos.
the class LogMessageHandlerImpl method handleEvent.
@Override
public Optional<LogMessage> handleEvent(V4Event e) {
V4MessageSent messageSent = e.getPayload().getMessageSent();
if (messageSent != null) {
V4Message m = messageSent.getMessage();
String messageML = m.getMessage();
if (messageML.contains(getHashTagId())) {
Optional<LogMessage> lm = readMessage(m);
if ((lm.isPresent()) && (lm.get().getCluster().equals(clusterName))) {
return lm;
}
}
}
return Optional.empty();
}
use of com.symphony.api.model.V4MessageSent in project spring-bot by finos.
the class BotIT method testSendMessageRoomWithMention.
@Test
public void testSendMessageRoomWithMention() throws JsonProcessingException {
Mention m = new Mention();
m.setId(new ArrayList<>());
m.getId().add(new UserId("1234"));
EntityJson ej = new EntityJson();
ej.put("m1", m);
String data = symphonyObjectMapper.writeValueAsString(ej);
V4Event in = new V4Event().initiator(new V4Initiator().user(new V4User().email("rob@example.com").displayName("Rob Example").userId(2438923l))).payload(new V4Payload().messageSent(new V4MessageSent().message(new V4Message().message("<div>hello</div>").stream(new V4Stream().streamId("ABC123").streamType("ROOM")).data(data))));
getPublicBot().sendToConsumer(in);
littleSleep();
wireMockRule.verify(1, WireMock.postRequestedFor(urlPathMatching("/agent/v4/stream/ABC123/message/create")));
}
use of com.symphony.api.model.V4MessageSent in project spring-bot by finos.
the class BotIT method testSendMessageIM.
@Test
public void testSendMessageIM() {
V4Event in = new V4Event().initiator(new V4Initiator().user(new V4User().email("rob@example.com").displayName("Rob Example").userId(2438923l))).payload(new V4Payload().messageSent(new V4MessageSent().message(new V4Message().message("<div>hello</div>").data("{}").stream(new V4Stream().streamId("ABC123").streamType("IM")))));
getPublicBot().sendToConsumer(in);
littleSleep();
wireMockRule.verify(1, WireMock.postRequestedFor(urlPathMatching("/agent/v4/stream/ABC123/message/create")));
}
use of com.symphony.api.model.V4MessageSent in project spring-bot by finos.
the class BotIT method testSendMessageRoomWithoutSlash.
@Test
public void testSendMessageRoomWithoutSlash() {
V4Event in = new V4Event().initiator(new V4Initiator().user(new V4User().email("rob@example.com").displayName("Rob Example").userId(2438923l))).payload(new V4Payload().messageSent(new V4MessageSent().message(new V4Message().message("<div>hello</div>").data("{}").stream(new V4Stream().streamId("ABC123").streamType("ROOM")))));
getPublicBot().sendToConsumer(in);
littleSleep();
// we shouldn't see a message sent
wireMockRule.verify(0, WireMock.postRequestedFor(urlPathMatching("/agent/v4/stream/ABC123/message/create")));
}
use of com.symphony.api.model.V4MessageSent in project spring-bot by finos.
the class KoreAIEventHandler method accept.
@Override
public void accept(V4Event t) {
try {
V4MessageSent ms = t.getPayload().getMessageSent();
V4User u = t.getInitiator().getUser();
if (ms != null) {
V4Stream stream = ms.getMessage().getStream();
String text = extractText(ms);
EntityJson ej = parseEntityJson(ms.getMessage().getData());
if (!u.getEmail().equals(botIdentity.getEmail()) && (isAddressed(stream, ej, text))) {
try {
Address a = buildAddress(u, stream);
text = normalizeText(text);
requester.send(a, text);
} catch (Exception e) {
LOG.error("Couldn't handle message {}", ms);
}
}
}
// handle form submits
V4SymphonyElementsAction elements = t.getPayload().getSymphonyElementsAction();
if (elements != null) {
String formId = elements.getFormId();
if (formId.equals("koreai-choice")) {
@SuppressWarnings("unchecked") String button = ((Map<String, String>) elements.getFormValues()).get("action");
try {
Address a = buildAddress(u, elements.getStream());
requester.send(a, button);
} catch (Exception e) {
LOG.error("Couldn't handle form submission {}", ms);
}
}
}
} catch (Exception e) {
LOG.error("Couldn't handle stream event " + t, e);
}
}
Aggregations