use of org.olat.instantMessaging.model.Buddy in project OpenOLAT by OpenOLAT.
the class InstantMessageServiceTest method testGetBuddiesListenTo.
@Test
public void testGetBuddiesListenTo() {
DummyListener dummyListener = new DummyListener();
Identity chatter1 = JunitTestHelper.createAndPersistIdentityAsUser("Chat-1-" + UUID.randomUUID().toString());
Identity chatter2 = JunitTestHelper.createAndPersistIdentityAsUser("Chat-2-" + UUID.randomUUID().toString());
OLATResourceable chatResource = OresHelper.createOLATResourceableInstance(UUID.randomUUID().toString(), chatter1.getKey());
imService.listenChat(chatter1, chatResource, null, false, false, dummyListener);
imService.listenChat(chatter2, chatResource, "Chatter-2", true, true, dummyListener);
dbInstance.commitAndCloseSession();
// check if the buddies listen to the chat
List<Buddy> buddies = imService.getBuddiesListenTo(chatResource);
Assert.assertNotNull(buddies);
Assert.assertEquals(2, buddies.size());
// check the properties of buddy 1
Buddy buddy1 = buddies.get(0).getIdentityKey().equals(chatter1.getKey()) ? buddies.get(0) : buddies.get(1);
Assert.assertTrue(buddy1.getUsername().equals(chatter1.getName()));
Assert.assertFalse(buddy1.isAnonym());
Assert.assertFalse(buddy1.isVip());
// check the properties of buddy 2
Buddy buddy2 = buddies.get(0).getIdentityKey().equals(chatter2.getKey()) ? buddies.get(0) : buddies.get(1);
Assert.assertTrue(buddy2.getUsername().equals(chatter2.getName()));
Assert.assertTrue(buddy2.isAnonym());
Assert.assertTrue(buddy2.isVip());
}
use of org.olat.instantMessaging.model.Buddy in project OpenOLAT by OpenOLAT.
the class InstantMessagingMainController method loadNotifications.
private void loadNotifications() {
List<InstantMessageNotification> notifications = imService.getNotifications(getIdentity());
for (InstantMessageNotification notification : notifications) {
if (!showNewMessageHolder.contains(notification.getFromIdentityKey())) {
showNewMessageHolder.add(notification.getFromIdentityKey());
Buddy buddy = imService.getBuddyById(notification.getFromIdentityKey());
createShowNewMessageLink(buddy);
}
}
}
use of org.olat.instantMessaging.model.Buddy in project OpenOLAT by OpenOLAT.
the class InstantMessagingMainController method processInstantMessageEvent.
private void processInstantMessageEvent(InstantMessagingEvent imEvent) {
if (imEvent.getCommand().equals("message")) {
// user receives messages from an other user
Long fromId = imEvent.getFromId();
if (!chatMgrCtrl.hasRunningChat(imEvent.getChatResource())) {
// add follow up message to info holder
if (!showNewMessageHolder.contains(fromId)) {
Buddy buddy = imService.getBuddyById(fromId);
if (Presence.available.name().equals(imStatus) && !inAssessment) {
doOpenPrivateChat(new SyntheticUserRequest(getIdentity(), getLocale()), buddy);
} else {
showNewMessageHolder.add(fromId);
createShowNewMessageLink(buddy);
}
}
}
}
}
use of org.olat.instantMessaging.model.Buddy in project OpenOLAT by OpenOLAT.
the class IMBuddyListController method event.
@Override
protected void event(UserRequest ureq, Component source, Event event) {
// buddies list
if (source == toggleOffline) {
if (viewMode == ViewMode.onlineUsers) {
toggleOffline.setCustomDisplayText(translate("im.hide.offline.buddies"));
toggleOffline.setIconLeftCSS("o_icon o_icon-fw o_icon_status_available");
toggleOffline.setElementCssClass("o_im_hideofflineswitch");
loadRoster(ViewMode.offlineUsers);
} else {
toggleOffline.setCustomDisplayText(translate("im.show.offline.buddies"));
toggleOffline.setIconLeftCSS("o_icon o_icon-fw o_icon_status_unavailable");
toggleOffline.setElementCssClass("o_im_showofflineswitch");
loadRoster(ViewMode.onlineUsers);
}
} else if (source == toggleGroup) {
if (viewGroups) {
toggleGroup.setCustomDisplayText(translate("im.show.groups"));
toggleGroup.setElementCssClass("o_im_hidegroupswitch");
buddiesListContent.contextPut("viewGroups", Boolean.FALSE);
viewGroups = false;
} else {
toggleGroup.setCustomDisplayText(translate("im.hide.groups"));
toggleGroup.setElementCssClass("o_im_showgroupswitch");
buddiesListContent.contextPut("viewGroups", Boolean.TRUE);
viewGroups = true;
}
} else if (source instanceof Link) {
Link link = (Link) source;
if ("cmd.buddy".equals(link.getCommand())) {
Buddy buddy = (Buddy) link.getUserObject();
fireEvent(ureq, new OpenInstantMessageEvent(ureq, buddy));
}
}
}
use of org.olat.instantMessaging.model.Buddy in project OpenOLAT by OpenOLAT.
the class MembersTableController method doOpenChat.
private void doOpenChat(MemberView member, UserRequest ureq) {
Buddy buddy = imService.getBuddyById(member.getIdentityKey());
OpenInstantMessageEvent e = new OpenInstantMessageEvent(ureq, buddy);
ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, InstantMessagingService.TOWER_EVENT_ORES);
}
Aggregations