use of org.finos.symphony.toolkit.workflow.content.Chat in project spring-bot by finos.
the class ClaimController method add.
@ChatButton(value = NewClaim.class, buttonText = "add")
public List<Response> add(NewClaim sc, User u, Addressable from) {
OpenedClaim c = new OpenedClaim();
c.amount = sc.amount;
c.author = u;
c.description = sc.description;
c.status = Status.OPEN;
Chat approvalRoom = conversations.getExistingChat("Claim Approval Room");
return Arrays.asList(new WorkResponse(approvalRoom, c, WorkMode.VIEW), new MessageResponse(from, Message.of("Your claim has been sent to the Approval Room for processing")));
}
use of org.finos.symphony.toolkit.workflow.content.Chat in project spring-bot by finos.
the class PollController method poll.
@ChatButton(buttonText = "start", showWhen = WorkMode.EDIT, value = PollCreateForm.class)
public List<WorkResponse> poll(PollCreateForm cf, Chat r, User a) {
int[] i = { 0 };
List<String> options = Arrays.asList(cf.option1, cf.option2, cf.option3, cf.option4, cf.option5, cf.option6).stream().filter(s -> StringUtils.hasText(s)).collect(Collectors.toList());
ButtonList buttons = new ButtonList(options.stream().map(s -> new Button(PollController.class, "poll" + (i[0]++), Type.ACTION, s)).collect(Collectors.toList()));
HashTag id = new HashTag(UUID.randomUUID().toString());
Poll p = new Poll(options);
p.setPoller(a);
p.setQuestion(cf.getQuestion());
p.setOptions(options);
p.setId(id);
List<User> users = rooms.getChatMembers(r);
List<WorkResponse> out = users.stream().filter(u -> !isMe(u)).map(u -> createResponseForUser(cf, options, id, buttons, u)).collect(Collectors.toList());
out.add(new WorkResponse(r, p, WorkMode.VIEW));
doScheduling(p, cf, r);
return out;
}
use of org.finos.symphony.toolkit.workflow.content.Chat in project spring-bot by finos.
the class TestHandlerMapping method pressButton.
private void pressButton(String s) throws Exception {
EntityJson jsonObjects = new EntityJson();
jsonObjects.put("1", new SymphonyUser(123l, "gaurav", "gaurav@example.com"));
jsonObjects.put("2", new HashTag("SomeTopic"));
Chat r = new SymphonyRoom("The Room Where It Happened", "abc123");
User author = new SymphonyUser(ROB_EXAMPLE_ID, ROB_NAME, ROB_EXAMPLE_EMAIL);
Object fd = new StartClaim();
Action a = new FormAction(r, author, fd, s, jsonObjects);
Action.CURRENT_ACTION.set(a);
mc.accept(a);
}
use of org.finos.symphony.toolkit.workflow.content.Chat 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.content.Chat in project spring-bot by finos.
the class SymphonyConversationsImpl method ensureChat.
@Override
public SymphonyRoom ensureChat(Chat r, List<User> users, Map<String, Object> meta) {
String description = "";
String name = r.getName();
boolean isPublic = false;
description = (String) meta.getOrDefault(ROOM_DESCRIPTION, "");
isPublic = (boolean) meta.getOrDefault(ROOM_PUBLIC, false);
SymphonyRoom theRoom = null;
if (r instanceof SymphonyRoom) {
if (((SymphonyRoom) r).getStreamId() != null) {
theRoom = (SymphonyRoom) r;
} else {
theRoom = loadRoomByName(name);
}
}
if (theRoom == null) {
// create the room
V3RoomAttributes ra = new V3RoomAttributes().name(name).description(description)._public(isPublic).discoverable(isPublic);
V3RoomDetail detail = streamsApi.v3RoomCreatePost(ra, null);
String streamId = detail.getRoomSystemInfo().getId();
theRoom = new SymphonyRoom(name, streamId);
// next, we need to make sure that all of the admins are members of the room and owners.
List<Long> adminIds = getDefaultAdministrators().stream().filter(u -> u instanceof SymphonyUser).map(u -> (SymphonyUser) u).map(su -> Long.parseLong(su.getUserId())).filter(id -> id != null).collect(Collectors.toList());
for (Long user : adminIds) {
UserId u = new UserId().id(user);
rmApi.v1RoomIdMembershipAddPost(u, null, streamId);
rmApi.v1RoomIdMembershipPromoteOwnerPost(u, null, streamId);
}
LOG.info("Created room {} with admins {} ", theRoom, getDefaultAdministrators());
}
// next, ensure that all the users are in the room
String streamId = theRoom.getStreamId();
users.stream().filter(u -> u instanceof SymphonyUser).map(u -> (SymphonyUser) u).forEach(u -> rmApi.v1RoomIdMembershipAddPost(new UserId().id(Long.parseLong(u.getUserId())), null, streamId));
return theRoom;
}
Aggregations