예제 #1
0
        TimelineMessage ConstructSendMessage(string text, List <LocalFile> files = null)
        {
            var message         = new Message();
            var timelineMessage = new TimelineMessage
            {
                MessageInfo = message
            };

            message.PersonEmail = "You";
            message.Created     = DateTime.UtcNow;
            message.Text        = text;

            if (files != null && files.Count > 0)
            {
                message.Files         = new List <RemoteFile>();
                timelineMessage.Files = new List <TimelineMessage.File>();
                foreach (var i in files)
                {
                    RemoteFile.Thumbnail thumbnail = null;
                    if (i.LocalThumbnail != null)
                    {
                        thumbnail = new RemoteFile.Thumbnail()
                        {
                            Height = i.LocalThumbnail.Height,
                            Width  = i.LocalThumbnail.Width,
                            Mime   = i.LocalThumbnail.Mime,
                        };
                    }
                    message.Files.Add(new RemoteFile()
                    {
                        Name            = i.Name,
                        Size            = i.Size,
                        RemoteThumbnail = thumbnail,
                    });
                    timelineMessage.Files.Add(new TimelineMessage.File()
                    {
                        Name          = i.Name,
                        Size          = i.Size,
                        ThumbnailPath = i.LocalThumbnail?.Path,
                    });
                }
            }

            return(timelineMessage);
        }
예제 #2
0
 void MessageSet(TimelineMessage to, Message from)
 {
     if (to.MessageInfo == null)
     {
         return;
     }
     to.MessageInfo.Id              = from.Id;
     to.MessageInfo.SpaceId         = from.SpaceId;
     to.MessageInfo.SpaceType       = from.SpaceType;
     to.MessageInfo.PersonId        = from.PersonId;
     to.MessageInfo.PersonEmail     = from.PersonEmail;
     to.MessageInfo.ToPersonId      = from.ToPersonId;
     to.MessageInfo.ToPersonEmail   = from.ToPersonEmail;
     to.MessageInfo.Created         = from.Created;
     to.MessageInfo.IsSelfMentioned = from.IsSelfMentioned;
     to.MessageInfo.Text            = from.Text;
     to.MessageInfo.Files           = from.Files;
 }
        TimelineMessage BuildTimelineMessage(Message message)
        {
            var timelineMessage = new TimelineMessage();

            timelineMessage.MessageInfo = message;
            timelineMessage.Files       = new List <TimelineMessage.File>();

            if (message.Files != null && message.Files.Count > 0)
            {
                foreach (var item in message.Files)
                {
                    timelineMessage.Files.Add(new TimelineMessage.File()
                    {
                        Name          = item.Name,
                        Size          = item.Size,
                        ThumbnailPath = null,
                    });
                }
            }

            return(timelineMessage);
        }