public void PostNotification(ClientNotification notification, bool executeContentProviders) { string userId = Context.User.GetUserId(); ChatUser user = _repository.GetUserById(userId); ChatRoom room = _repository.VerifyUserRoom(_cache, user, notification.Room); // User must be an owner if (room == null || !room.Owners.Contains(user) || (room.Private && !user.AllowedRooms.Contains(room))) { throw new HubException(LanguageResources.PostNotification_NotAllowed); } var chatMessage = new ChatMessage { Id = Guid.NewGuid().ToString("d"), Content = notification.Content, User = user, Room = room, HtmlEncoded = false, ImageUrl = notification.ImageUrl, Source = notification.Source, When = DateTimeOffset.UtcNow, MessageType = (int)MessageType.Notification }; _repository.Add(chatMessage); _repository.CommitChanges(); Clients.Group(room.Name).addMessage(new MessageViewModel(chatMessage), room.Name); if (executeContentProviders) { var urls = UrlExtractor.ExtractUrls(chatMessage.Content); if (urls.Count > 0) { _resourceProcessor.ProcessUrls(urls, Clients, room.Name, chatMessage.Id); } } }
public void PostNotification(ClientNotification notification) { PostNotification(notification, executeContentProviders: true); }