Ejemplo n.º 1
0
        public int Post(thread id)
        {
            thread selected_thread = (from thread m in db.threads where m.groupKey.StartsWith(id.groupKey) select m).FirstOrDefault();

            MailMessage Message = new MailMessage();
            SmtpClient Smtp = new SmtpClient();

            string password = System.Web.Configuration.WebConfigurationManager.AppSettings["MailPassword"];

            System.Net.NetworkCredential SmtpUser = new System.Net.NetworkCredential("*****@*****.**", password);

            string email = "reported: \n\n";
            email = email + "http://authie.me/thread/" + selected_thread.groupKey + "\n\n";

            Message.From = new MailAddress("*****@*****.**");
            Message.To.Add(new MailAddress("*****@*****.**"));
            Message.IsBodyHtml = false;
            Message.Subject = "authie report";
            Message.Body = email;
            Message.Priority = MailPriority.Normal;
            Smtp.EnableSsl = false;

            Smtp.Credentials = SmtpUser;
            Smtp.Host = "198.57.199.92";
            Smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            Smtp.Port = 26;

            Smtp.Send(Message);

            return selected_thread.id ;
        }
Ejemplo n.º 2
0
        public int Post(thread id)
        {
            thread selected_thread = (from thread m in db.threads where m.groupKey.StartsWith(id.groupKey) select m).FirstOrDefault();
            int hearts = 1;

            if (int.TryParse(selected_thread.hearts.ToString(), out hearts) == false)
            {
                hearts = 1;
            };

            hearts = hearts + 1;

            selected_thread.hearts = hearts;

            db.threads.Attach(selected_thread);
            var updated_thread = db.Entry(selected_thread);

            updated_thread.Property(e => e.hearts).IsModified = true;
            db.SaveChanges();

            return hearts;
        }
Ejemplo n.º 3
0
        public async Task<RODResponseMessage> Post(Snap _snap)
        {

            RODResponseMessage msg = new RODResponseMessage();

            if (_snap == null)
            {
                msg.result = -1;
                msg.message = "Snap was null.";
                return msg;
            }

            string user_id = User.Identity.Name;
            handle logged_in = (from handle r in db.handles where r.userGuid.Equals(User.Identity.Name) select r).FirstOrDefault();
            handle to_handle = (from handle r in db.handles where r.publicKey == _snap.toGuid select r).FirstOrDefault();


            // check to make sure that the thread sender 
            // is not blocked by the recipent
            block blocked = (from m in db.blocks
                             where m.blockedByHandleId == to_handle.id
                                 && m.blockedHandleId == logged_in.id && m.active == 1
                             select m).FirstOrDefault();
            if (blocked != null)
            {
                // bail out, don't send the message
                msg.result = -1;
                msg.message = "Unable to send message.";
                return msg;
            }


            thread clean_thread = new thread();
            clean_thread.active = 1;
            clean_thread.startDate = DateTime.UtcNow;
            clean_thread.fromHandleId = logged_in.id;
            clean_thread.caption = _snap.caption;
            clean_thread.hearts = 0;
            clean_thread.toHandleId = to_handle.id;
            clean_thread.location = _snap.location;
            clean_thread.font = _snap.font;
            clean_thread.textColor = _snap.textColor;

            //
            // check to see if the to_handle is authorized
            // to make the send, if they are not, then this is
            // an authorization request. 
            //
            clean_thread.authorizeRequest = 0;

            //
            // we don't need to do this check if this is for
            // toHandleId = 1 or toHandleId = 2 (snaps sent
            // to profile and the daily)
            //

            if (clean_thread.toHandleId != 1 && clean_thread.toHandleId != 2)
            {

                follower confirmed_to_handle_follower = (from m in db.followers
                                                         where m.followeeId == to_handle.id &&
                                                         m.followerId == logged_in.id &&
                                                         m.active == 1
                                                         select m).FirstOrDefault();

                if (confirmed_to_handle_follower == null)
                {
                    clean_thread.authorizeRequest = 1;
                }

            }

            // should it all be organized around this group key then?
            // add new threads and messages at the same with the same
            // group key generated on the client (like a guid)...

            clean_thread.groupKey = _snap.groupKey;
            db.threads.Add(clean_thread);
            db.SaveChanges();

            if (_snap.caption != null)
            {

                if (_snap.caption.Length > 0)
                {
                    message chat_message = new message();
                    chat_message.threadId = clean_thread.id;
                    chat_message.messageText = clean_thread.caption;
                    chat_message.fromHandleId = clean_thread.fromHandleId;
                    chat_message.sentDate = DateTime.UtcNow;
                    chat_message.toHandleId = to_handle.id;
                    db.messages.Add(chat_message);
                    db.SaveChanges();
                }
            }

            msg.message = clean_thread.id.ToString();
            msg.result = 1;


            return msg;
        }