public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var character = request.Session.Character;
                var targets   = request.Data.GetOrDefault <int[]>(k.target).ToCharacter().ToArray();
                var subject   = request.Data.GetOrDefault <string>(k.subject);
                var body      = request.Data.GetOrDefault <string>(k.body);

                var filteredTargets = character.FilterWhoBlockedMe(targets).ToArray();

                filteredTargets.Length.ThrowIfEqual(0, ErrorCodes.TargetBlockedTheRequest);

                var mail = new MassMail
                {
                    body    = body,
                    subject = subject,
                    sender  = character,
                    folder  = MailFolder.inbox,
                    targets = filteredTargets,
                    type    = MailType.character
                };

                //write to targets' inboxes
                MassMailer.WriteMailToTargets(mail).ThrowIfError();

                //write to sender's inbox
                MassMailer.WriteToOutbox(mail).ThrowIfError();

                var result = MassMailer.ListFolder(character, (int)MailFolder.outbox).ToDictionary("m", m => m.ToSimpleDictionary());
                Message.Builder.FromRequest(request).WithData(result).Send();

                scope.Complete();
            }
        }
Ejemplo n.º 2
0
        public void HandleRequest(IRequest request)
        {
            var character = request.Session.Character;
            var folder    = request.Data.GetOrDefault <int>(k.folder);

            var result = MassMailer.ListFolder(character, folder).ToDictionary("m", m => m.ToSimpleDictionary());

            Message.Builder.FromRequest(request).WithData(result).Send();
        }