use of org.olat.instantMessaging.InstantMessage in project openolat by klemens.
the class ChatController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == chatPanelCtr) {
fireEvent(ureq, new CloseInstantMessagingEvent(getOlatResourceable()));
allChats.remove(Integer.toString(hashCode()));
jsc.setRefreshIntervall(5000);
} else if (source == sendMessageForm) {
if (StringHelper.containsNonWhitespace(sendMessageForm.getMessage())) {
InstantMessage message = doSendMessage(sendMessageForm.getMessage());
appendToMessageHistory(message, true);
sendMessageForm.resetTextField();
} else {
// ignore empty manObjectessage entry and refocus on entry field
chatMsgFieldContent.contextPut("chatMessages", messageHistory);
chatMsgFieldContent.contextPut("focus", Boolean.TRUE);
}
} else if (source == rosterCtrl) {
doSendPresence(rosterCtrl.getNickName(), rosterCtrl.isUseNickName());
}
}
use of org.olat.instantMessaging.InstantMessage in project openolat by klemens.
the class ChatLogHelper method logMediaResource.
public MediaResource logMediaResource(OLATResourceable ores, Locale locale) {
Translator translator = Util.createPackageTranslator(ChatController.class, locale);
String tableExportTitle = translator.translate("logChat.export.title");
String label = tableExportTitle + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".xlsx";
return new OpenXMLWorkbookResource(label) {
@Override
protected void generate(OutputStream out) {
try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1)) {
// headers
OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
Row headerRow = exportSheet.newRow();
headerRow.addCell(0, "User", workbook.getStyles().getHeaderStyle());
headerRow.addCell(1, "Date", workbook.getStyles().getHeaderStyle());
headerRow.addCell(2, "Content", workbook.getStyles().getHeaderStyle());
// content
List<InstantMessage> messages = imDao.getMessages(ores, null, 0, -1);
for (InstantMessage message : messages) {
Row dataRow = exportSheet.newRow();
dataRow.addCell(0, message.getFromNickName(), null);
dataRow.addCell(1, message.getCreationDate(), workbook.getStyles().getDateStyle());
dataRow.addCell(2, message.getBody(), null);
}
} catch (IOException e) {
log.error("", e);
}
}
};
}
use of org.olat.instantMessaging.InstantMessage in project openolat by klemens.
the class InstantMessagingServiceImpl method sendPrivateMessage.
@Override
public InstantMessage sendPrivateMessage(Identity from, Long toIdentityKey, String body, OLATResourceable chatResource) {
String name = userManager.getUserDisplayName(from);
InstantMessage message = imDao.createMessage(from, name, false, body, chatResource);
imDao.createNotification(from.getKey(), toIdentityKey, chatResource);
// commit before sending event
dbInstance.commit();
InstantMessagingEvent event = new InstantMessagingEvent("message", chatResource);
event.setFromId(from.getKey());
event.setName(name);
event.setAnonym(false);
event.setMessageId(message.getKey());
// general event
coordinator.getCoordinator().getEventBus().fireEventToListenersOf(event, chatResource);
// buddy event
OLATResourceable buddy = OresHelper.createOLATResourceableInstance("Buddy", toIdentityKey);
coordinator.getCoordinator().getEventBus().fireEventToListenersOf(event, buddy);
return message;
}
use of org.olat.instantMessaging.InstantMessage in project openolat by klemens.
the class InstantMessagingServiceImpl method sendMessage.
@Override
public InstantMessage sendMessage(Identity from, String fromNickName, boolean anonym, String body, OLATResourceable chatResource) {
InstantMessage message = imDao.createMessage(from, fromNickName, anonym, body, chatResource);
// commit before sending event
dbInstance.commit();
InstantMessagingEvent event = new InstantMessagingEvent("message", chatResource);
event.setFromId(from.getKey());
event.setName(fromNickName);
event.setAnonym(anonym);
event.setMessageId(message.getKey());
coordinator.getCoordinator().getEventBus().fireEventToListenersOf(event, chatResource);
return message;
}
Aggregations