use of org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction in project spring-bot by finos.
the class TestHandlerMapping method execute.
private void execute(String s) throws Exception {
EntityJson jsonObjects = new EntityJson();
jsonObjects.put("1", new SymphonyUser(123l, "gaurav", "gaurav@example.com"));
jsonObjects.put("2", new Taxonomy(Arrays.asList(new HashTag("SomeTopic"))));
Message m = smp.parse("<messageML>/" + s + "</messageML>", jsonObjects);
Chat r = new SymphonyRoom("The Room Where It Happened", "abc123");
User author = new SymphonyUser(ROB_EXAMPLE_ID, ROB_NAME, ROB_EXAMPLE_EMAIL);
Action a = new SimpleMessageAction(r, author, m, jsonObjects);
Action.CURRENT_ACTION.set(a);
mc.accept(a);
}
use of org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction in project spring-bot by finos.
the class TestHandlerMapping method getMappingsFor.
private List<ChatMapping<ChatRequest>> getMappingsFor(String s) throws Exception {
EntityJson jsonObjects = new EntityJson();
Message m = smp.parse("<messageML>" + s + "</messageML>", jsonObjects);
Action a = new SimpleMessageAction(null, null, m, jsonObjects);
return hm.getHandlers(a);
}
use of org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction in project spring-bot by finos.
the class PresentationMLHandler method accept.
@Override
public void accept(V4Event t) {
try {
V4MessageSent ms = t.getPayload().getMessageSent();
if ((ms != null) && (!ms.getMessage().getUser().getEmail().equals(botIdentity.getEmail()))) {
// ok, this is a message, and it's from a third party. Parse it.
EntityJson ej = jsonConverter.readValue(ms.getMessage().getData());
Message words = messageParser.parse(ms.getMessage().getMessage(), ej);
Addressable rr = ruBuilder.loadRoomById(ms.getMessage().getStream().getStreamId());
User u = ruBuilder.loadUserById(ms.getMessage().getUser().getUserId());
// TODO: multi-user chat (not room)
rr = rr == null ? u : rr;
SimpleMessageAction sma = new SimpleMessageAction(rr, u, words, ej);
try {
Action.CURRENT_ACTION.set(sma);
for (ActionConsumer c : messageConsumers) {
c.accept(sma);
}
} finally {
Action.CURRENT_ACTION.set(Action.NULL_ACTION);
}
}
} catch (Exception e) {
LOG.error("Couldn't handle event " + t, e);
}
}
Aggregations