use of com.symphony.user.StreamID in project spring-bot by finos.
the class AbstractStreamResolving method getStreamIdForUser.
protected String getStreamIdForUser(SymphonyUser a) {
if (((SymphonyUser) a).getStreamId() != null) {
return ((SymphonyUser) a).getStreamId();
} else {
long userId = getUserIdForUser(a);
Stream s = streamsApi.v1ImCreatePost(Collections.singletonList(userId), null);
a.getId().add(new StreamID(s.getId()));
return s.getId();
}
}
use of com.symphony.user.StreamID 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;
}
use of com.symphony.user.StreamID in project spring-bot by finos.
the class SymphonyConversationsImpl method loadUserByStreamAttributes.
protected SymphonyUser loadUserByStreamAttributes(StreamAttributes si) {
if (si.getStreamAttributes().getMembers().size() != 2) {
return null;
} else {
Long userId = si.getStreamAttributes().getMembers().stream().filter(id -> id != botUserId).findFirst().orElse(null);
if (userId == null) {
return null;
}
SymphonyUser out = new SymphonyUser(userId);
out.getId().add(new StreamID(si.getId()));
return out;
}
}
Aggregations