public void AddUserToGroup(Models.Chat chat, Models.ChatUser chatUser) { if (!chat.IsGroup || chat.Setting == null) { return; } var chatUserData = new Models.View.ChatUser(chatUser); chatUser.User?.DeviceIds?.ForEach(deviceId => { SendMessage( deviceId.DeviceId, chat.Id.ToString(), chat.Setting.Name, "user_added", chatUserData, true, MessagePriority.high ).ConfigureAwait(false); }); SendMessage( "/topics/group_" + chat.Setting.Address, chat.Id.ToString(), chat.Setting.Name, "user_added", chatUserData, true, MessagePriority.high ).ConfigureAwait(false); }
public void SetUserGroupRank(Models.Chat chat, Models.ChatUser chatUser) { if (!chat.IsGroup || chat.Setting == null) { return; } SendMessage( "/topics/group_" + chat.Setting.Address, chat.Id.ToString(), chat.Setting.Name, "user_rank", new Models.View.ChatUser(chatUser), true, MessagePriority.high ).ConfigureAwait(false); }
public override void Execute(CommandContext context, CallerContext callerContext, Models.ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Who are you trying to kick?"); } ChatRoom room = context.Repository.VerifyUserRoom(context.Cache, callingUser, callerContext.RoomName); if (context.Repository.GetOnlineUsers(room).Count() == 1) { throw new InvalidOperationException("You're the only person in here..."); } string targetUserName = HttpUtility.HtmlDecode(args[0]); ChatUser targetUser = context.Repository.VerifyUser(targetUserName); context.Service.KickUser(callingUser, targetUser, room); context.NotificationService.KickUser(targetUser, room); context.Repository.CommitChanges(); }
public override void Execute(CommandContext context, CallerContext callerContext, Models.ChatUser callingUser, string[] args) { ChatRoom room = context.Repository.VerifyUserRoom(context.Cache, callingUser, callerContext.RoomName); context.Service.SetInviteCode(callingUser, room, RandomUtils.NextInviteCode()); context.NotificationService.PostNotification(room, callingUser, String.Format("Invite Code for this room: {0}", room.InviteCode)); }
public override void ExecuteAdminOperation(CommandContext context, CallerContext callerContext, Models.ChatUser callingUser, string[] args) { string messageText = String.Join(" ", args).Trim(); if (String.IsNullOrEmpty(messageText)) { throw new HubException(LanguageResources.Broadcast_MessageRequired); } context.NotificationService.BroadcastMessage(callingUser, messageText); }
public override void ExecuteAdminOperation(CommandContext context, CallerContext callerContext, Models.ChatUser callingUser, string[] args) { string messageText = String.Join(" ", args).Trim(); if (String.IsNullOrEmpty(messageText)) { throw new InvalidOperationException("What did you want to broadcast?"); } context.NotificationService.BroadcastMessage(callingUser, messageText); }
public ChatUser(Models.ChatUser chatUser) : base(chatUser.User) { Rank = chatUser.Rank; JoinedAt = chatUser.JoinedAt; }
public override void ExecuteAdminOperation(CommandContext context, CallerContext callerContext, Models.ChatUser callingUser, string[] args) { string messageText = String.Join(" ", args).Trim(); if (String.IsNullOrEmpty(messageText)) { throw new InvalidOperationException("What did you want to broadcast?"); } HashSet <string> urls; var transform = new TextTransform(context.Repository); messageText = transform.Parse(messageText); messageText = TextTransform.TransformAndExtractUrls(messageText, out urls); context.NotificationService.BroadcastMessage(callingUser, messageText); }