public function onUserFollowed(ServiceEvent $event) { $friend = $event->getSubject(); $user = $this->getUserService()->getUser($friend['fromId']); $message = array('userId' => $user['id'], 'userName' => $user['nickname'], 'opration' => 'follow'); $this->getNotificationService()->notify($friend['toId'], 'user-follow', $message); $message = array('fromId' => $friend['fromId'], 'toId' => $friend['toId'], 'type' => 'text', 'title' => '好友添加', 'content' => $user['nickname'] . '添加你为好友', 'custom' => json_encode(array('fromId' => $friend['fromId'], 'nickname' => $user['nickname'], 'typeBusiness' => 'verified'))); $tuiClient = new EdusohoTuiClient(); $result = $tuiClient->sendMessage($message); }
public function onMessageSended(ServiceEvent $event) { $message = $event->getSubject(); $user = $this->getUserService()->getUser($message['fromId']); $largeAvatar = empty($user['largeAvatar']) ? '' : $this->getFileService()->parseFileUri($user['largeAvatar']); $message['title'] = $user['nickname']; $host = 'http://' . $_SERVER['HTTP_HOST']; $message['custom'] = json_encode(array('fromId' => $message['fromId'], 'nickname' => $user['nickname'], 'imgUrl' => empty($largeAvatar) ? $host . '/assets/img/default/avatar.png' : $host . '/files/' . $largeAvatar['path'], 'typeMsg' => $message['type'], 'typeBusiness' => in_array('ROLE_TEACHER', $user['roles']) ? 'teacher' : 'friend', 'createdTime' => time())); $tuiClient = new EdusohoTuiClient(); $result = $tuiClient->sendMessage($message); }