Ejemplo n.º 1
0
        protected override XElement[] Do(WebContext context)
        {
            Account receiver;

            if (context.httprequest.Form.AllKeys.Contains("receiverId"))
            {
                receiver = Account.LoadById(int.Parse(context.httprequest.Form["receiverId"]));
            }
            else if (context.httprequest.Form.AllKeys.Contains("receiverName"))
            {
                receiver = Account.LoadByUser(User.LoadByName(context.httprequest.Form["receiverName"]));
            }
            else
            {
                throw new ApplicationException("receiverId/receiverName not passed");
            }

            if (Config.instance.IsMigrationEnabled && receiver.needsMigration)
            {
                throw new ApplicationException("User is not migrated");
            }

            PMMessage newMessage = PMConversation.SendPMMessage(
                context.account,
                receiver,
                this.getTitle(context),
                this.getBody(context)
                );

            newMessage.conversation.markAsRead(context.session.account, newMessage, newMessage);

            return(new XElement[] { newMessage.exportToXml(context) });
        }
Ejemplo n.º 2
0
        public async override Task <Message> HandleMessage(Message msg)
        {
            PMMessage pm = msg as PMMessage;

            if (pm is null)
            {
                return(null);
            }

            MessageContext context          = new MessageContext(msg, this);
            string         sfConversationID = Smart.Format(ConversationID, context);
            string         sfArchiveURL     = Smart.Format(ArchiveURL, sfConversationID);

            try
            {
                var thing = await Client.GetThingByFullnameAsync(sfConversationID);

                await Agent.Post(sfArchiveURL, null);
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"{ex.GetType().Name} thrown when archiving conversation: {ex.Message}");
            }

            return(msg);
        }
Ejemplo n.º 3
0
        /**
         * Packet: 0x53
         * Length: 2 bytes
         *
         * Sends a PopupMessage with a predetermined message
         */
        public static void SendPopupMessage(this NetState ns, PMMessage msg)
        {
            if (ns != null && ns.GetSendBuffer(out var buffer))
            {
                buffer[0] = 0x53; // Packet ID
                buffer[1] = (byte)msg;

                ns.Send(ref buffer, 2);
            }
        }
Ejemplo n.º 4
0
        override protected IEnumerable <XElement> getSpecificNewMessageData(WebContext context)
        {
            PMMessage message = this.url.pm;
            string    quoted  = UBBParser.StripQuotes(message.bodyUBB).Trim();

            return(new XElement[] {
                message.exportToXml(context),
                new XElement("quoted", quoted),
            });
        }
Ejemplo n.º 5
0
 public PopupMessage( PMMessage msg )
     : base(0x53, 2)
 {
     m_Stream.Write( (byte)msg );
 }
Ejemplo n.º 6
0
 public PopupMessage(PMMessage msg) : base(0x53, 2)
 {
     Stream.Write((byte)msg);
 }
Ejemplo n.º 7
0
 // Methods
 public PopupMessage(PMMessage msg) : base(83, 2)
 {
     this.m_Stream.Write(((byte)msg));
 }
Ejemplo n.º 8
0
 public Reply(string pmId, string remainder) : base(remainder)
 {
     this.pm = PMMessage.LoadById(int.Parse(pmId));
 }
Ejemplo n.º 9
0
 public Reply(string pmId, string remainder)
     : base(remainder)
 {
     this.pm = PMMessage.LoadById(int.Parse(pmId));
 }