Exemplo n.º 1
0
        protected IActivityObject GetDalObject(Activity activity)
        {
            //Logger.Instance.Debug($"getting dal object for type {Type} with Id {Id}");
            switch (Type)
            {
            case "user":
                return(Users.GetById((uint)Id));

            case "sitegroup_group":
                return(Groups.GetById((uint)Id));

            case "sitepage_page":
                return(Pages.GetById((uint)Id));

            case "album_photo":
                return(AlbumPhotos.GetById((uint)Id));

            case "core_link":
                return(CoreLinks.GetById((uint)Id));

            default:
                //throw new Exception($"Unknown type {Type} for Dal Object for entity type {_entityType}");
                return(new DummeyActivityObject());
            }
        }
Exemplo n.º 2
0
        public FeedAttachmentCore(ActivityAttachment attachment, ulong actionId)
        {
            var coreLink = CoreLinks.GetById(attachment.id);

            title = coreLink.title;
            body  = HttpUtility.HtmlDecode(coreLink.description);
            //uri = $"https://beta.koobeca.com/core/link/index/id/{coreLink.link_id}/key/{Md5.CalculateMd5Hash(coreLink.link_id + coreLink.uri)}/action_id/{actionId}";
            uri        = $"https://beta.koobeca.com/view.php?action_id={actionId}";
            image_main = coreLink.photo_id > 0 ? new FeedImage(coreLink.photo_id) : null;
            if (image_main == null)   // && !string.IsNullOrEmpty(coreLink.@params)){
            {
                var iframely = coreLink.GetIFramely();
                if (iframely != null)
                {
                    try {
                        image_main = new FeedImage(iframely);
                    }
                    catch {
                        Logger.Instance.Error($"Bad iframley in corelink {coreLink.link_id} : {coreLink.@params}");
                    }
                }
            }

            attachment_id = attachment.id;
            mode          = (uint)(attachment.mode ? 1 : 0);
        }
Exemplo n.º 3
0
        private void HandleFBVideos()
        {
            try
            {
                var videoId = GetFBVideoId(activity.RawActivity.BodyStr); //try the body first
                if (!string.IsNullOrEmpty(videoId))
                {
                    activity.RawActivity.body = null;
                }
                else if (activity.RawActivity.Attachments.Any(a => a.type == "core_link"))
                {
                    //look inside the core link
                    var linkId = activity.RawActivity.Attachments.First(a => a.type == "core_link").id;
                    videoId = GetFBVideoId(CoreLinks.GetById(linkId).uri);
                }

                if (string.IsNullOrEmpty(videoId))
                {
                    return;
                }

                var videoData = GetVideoDataFromFB(videoId);

                //else

                //clean all existing attachments
                ActivityAttachments.DeleteForActivity(activity.ActivityId);
                ;
                //build the video attachment
                //var urls = new { video = iframely.url, thumb = iframely.links.thumbnail[0].href };
                Video newVideo = new Video()
                {
                    code        = videoData["code"],
                    description = videoData["description"],
                    title       = videoData["title"],
                    owner_id    = (int)activity.OwnerId,
                    owner_type  = activity.OwnerType,
                    type        = "fb"
                };

                AddVideoAttachmentToActivity(newVideo, activity);
                activity.RawActivity.body = Encoding.UTF8.GetBytes(FilterUrlFromBody(activity.RawActivity.BodyStr));
            }
            catch
            {
                Logger.Instance.Debug($"Failed to attach FB video");
                return;
            }
        }
Exemplo n.º 4
0
        public IActivityObject GetActivityObject()
        {
            switch (type)
            {
            case "core_link":
                return(CoreLinks.GetById(id));

            case "album_photo":
                return(AlbumPhotos.GetById(id));

            case "video":
                return(Videos.GetById(id));

            default:
                return(null);
            }
        }
Exemplo n.º 5
0
        private void SetLinkParent()
        {
            var attachments = activity.RawActivity.Attachments;

            if (attachments == null)
            {
                return;
            }

            foreach (var linkId in attachments.Where(a => a.type == "core_link").Select(a => a.id))
            {
                Logger.Instance.Debug($"setting parent of link {linkId} to action {activity.ActivityId}");
                var link = CoreLinks.GetById(linkId);
                link.parent_id   = (uint)activity.ActivityId;
                link.parent_type = "activity_action";

                CoreLinks.UpdateParent(linkId, activity.ActivityId, "activity_action");
            }
        }
Exemplo n.º 6
0
 public CoreLink Get(uint linkId)
 {
     ///
     return(CoreLinks.GetById(linkId));
 }