Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        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));
        }
Beispiel #5
0
        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);
        }
Beispiel #7
0
 public ChatUser(Models.ChatUser chatUser)
     : base(chatUser.User)
 {
     Rank     = chatUser.Rank;
     JoinedAt = chatUser.JoinedAt;
 }
Beispiel #8
0
        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);
        }