Example #1
0
        public static ISnesActivity CreateActivity(OpenSocialActivity openSocialActivity, SnesActivityData activityData)
        {
            CommentActivityBase activityBase;
            
            if (activityData.BlogUrl == null)
            {
                activityBase = PolicyInjection.Create<MessageBoardPostActivity>(openSocialActivity, activityData);
            }
            else
            {
                if (activityData.Rating == null)
                {
                    activityBase = PolicyInjection.Create<CommentForumActivity>(openSocialActivity, activityData);    
                }
                else
                {
                    activityBase = PolicyInjection.Create<ReviewActivity>(openSocialActivity, activityData);
                }
            }
            
            activityBase.Application = activityData.AppInfo.AppId;
            
            activityBase.SetTitle(openSocialActivity, activityData);
            activityBase.SetObjectTitle(openSocialActivity, activityData);
            activityBase.SetObjectDescription(openSocialActivity, activityData);
            activityBase.SetObjectUri(openSocialActivity, activityData);

            return activityBase;
        }
Example #2
0
 public CommentForumActivity(OpenSocialActivity openSocialActivity, SnesActivityData eventData)
 {
     Contents = openSocialActivity;
     Contents.ActivityType = openSocialActivity.CustomActivityType;
     if (string.IsNullOrEmpty(Contents.ActivityType))
     {
         Contents.ActivityType = "comment";
     }
     IdentityUserId = eventData.IdentityUserId;
     ActivityId = eventData.EventId;
 }
Example #3
0
 public ReviewActivity(OpenSocialActivity activity, SnesActivityData eventData)
 {
     Contents = activity;
     Contents.ActivityType = activity.CustomActivityType;
     if (string.IsNullOrEmpty(Contents.ActivityType))
     {
         Contents.ActivityType = "review";
     }
     
     IdentityUserId = eventData.IdentityUserId;
     ActivityId = eventData.EventId;
 }
 public static ISnesActivity CreateActivity(OpenSocialActivity openSocialActivity, 
     SnesActivityData activityData)
 {
     var activity = new RevokeCommentActivity
                        {
                            ActivityId = activityData.EventId,
                            PostedTime = openSocialActivity.PostedTime,
                            IdentityUserId = activityData.IdentityUserId,
                            ApplicationId = activityData.AppInfo.AppId
                        };
     return activity;
 }
        public void RevokeCommentActivity_SubmitActivityAndRevoke_Success()
        {
            var logger = MockRepository.GenerateStub<IDnaLogger>();
            
            DateTime now = DateTime.Now;
            
            var httpClient = GetHttpClient();

            var openSocialActivity = new OpenSocialActivity
                                         {
                                             PostedTime = now.MillisecondsSinceEpoch()
                                         };
            var eventData = new SnesActivityData
                                {
                                    ActivityType = 19,
                                    AppInfo = new DnaApplicationInfo
                                                  {
                                                      AppId = "testApplication"
                                                  },
                                    BlogUrl = "http://www.example.com/blogurl",
                                    UrlBuilder = new DnaUrlBuilder
                                                     {
                                                         DnaUrl = "http://www.example.com/dna/",
                                                         ForumId = 1,
                                                         PostId = 1,
                                                         ThreadId = 1
                                                     },
                                    IdentityUserId = "0"

                                };

            var activity = CommentActivityBase.CreateActivity(openSocialActivity, eventData);
            activity.Send(httpClient);

            var revokeActivity = RevokeCommentActivity.CreateActivity(openSocialActivity, eventData);
            revokeActivity.Send(httpClient);

            var getActivity = new SnesActivitiesQuery
                                  {
                                      FilterBy = "postedTime",
                                      FilterOp = "equals",
                                      FilterValue = now.ToString(),
                                      IdentityUserId = "0",
                                  };
            var statusCode =  getActivity.Send(httpClient);
            Assert.AreEqual(HttpStatusCode.InternalServerError, statusCode);
        }
        public void CommentActivityDataContract_Serialize()
        {
            var comment = new OpenSocialActivity();

            comment.Title = "A title";
            comment.Body = "A body";
            comment.DisplayName = "mooks";
            comment.PostedTime = 1234567890;
            comment.Url = new Uri("http://www.bbc.co.uk/dna/h2g2/F1",UriKind.RelativeOrAbsolute);
            comment.UserName = "******";
            comment.ObjectDescription = "An object description";
            comment.ObjectUri = "/dna/h2g2/F1";
            comment.ObjectTitle = "A title";

            string json = comment.SerializeToJson();

            Assert.IsTrue(json.Contains("\"title\":\"A title\""));

        }
Example #7
0
        public void ReviewActivity_Create()
        {
            var openSocialActivity = new OpenSocialActivity();
            var eventData = new SnesActivityData();

            openSocialActivity.ActivityType = "review";
            openSocialActivity.Body = "some content";
            openSocialActivity.DisplayName = "mooks";
            openSocialActivity.Id = "1234";
            openSocialActivity.ObjectDescription = "some description";
            openSocialActivity.ObjectTitle = "some title";
            openSocialActivity.ObjectUri = "http://www.example.com/someuri";
            openSocialActivity.PostedTime = DateTime.Now.MillisecondsSinceEpoch();
            openSocialActivity.Title = "some title";
            openSocialActivity.Url = new Uri("http://www.example.com/someurl",UriKind.RelativeOrAbsolute);
            openSocialActivity.UserName = "******";

            eventData.ActivityType = 19;
            eventData.AppInfo = new DnaApplicationInfo { AppId = "iplayer", ApplicationName = "iplayer video" };
            
            eventData.BlogUrl = "http://www.example.com/blogurl";
            eventData.EventId = 1;
            eventData.IdentityUserId = "12345";

            eventData.Rating = new Rating { MaxValue = 5, Value = 4 };
            eventData.UrlBuilder = new DnaUrlBuilder { DnaUrl = "iplayer", ForumId = 1, PostId = 1, ThreadId = 1 };

            var logger = MockRepository.GenerateStub<IDnaLogger>();

            var activity = CommentActivityBase.CreateActivity(openSocialActivity, eventData);

            Stopwatch sw = new Stopwatch();
            sw.Start();
            var json = activity.GetActivityJson();
            var uri = activity.GetUri();
            sw.Stop();

            long millis = sw.ElapsedMilliseconds;



        }
Example #8
0
        public override void SetTitle(OpenSocialActivity openSocialActivity, SnesActivityData eventData)
        {
            try
            {
                Contents.Url = new Uri(openSocialActivity.ContentPermaUrl, UriKind.RelativeOrAbsolute);
            }
            catch { }

            if (Contents.Url == null || String.IsNullOrEmpty(Contents.Url.OriginalString))
            {
                if (eventData.BlogUrl.Length > 0)
                {
                    Contents.Url = new Uri(eventData.BlogUrl + "#P" + eventData.UrlBuilder.PostId, UriKind.RelativeOrAbsolute);
                }

            }
           

            Contents.Title =
                CreateTitleString(eventData, "posted", Contents.Url, eventData.BlogUrl);
        }
        public override void SetTitle(OpenSocialActivity openSocialActivity, SnesActivityData eventData)
        {
            int postId = eventData.UrlBuilder.PostId;
            string url = eventData.UrlBuilder.DnaUrl;
            int forumId = eventData.UrlBuilder.ForumId;
            int threadId = eventData.UrlBuilder.ThreadId;
            string activityHostNameUrl = "http://www.bbc.co.uk/dna/" + url;
            try
            {
                Contents.Url = new Uri(openSocialActivity.ContentPermaUrl, UriKind.RelativeOrAbsolute);
            }
            catch { }

            if (String.IsNullOrEmpty(Contents.Url.ToString()))
            {
                Contents.Url = new Uri(activityHostNameUrl + "/F" + forumId + "?thread=" + threadId + "#p" + postId,
                                       UriKind.RelativeOrAbsolute);
            }

            Contents.Title = CreateTitleString(eventData, "posted", Contents.Url, activityHostNameUrl);
        }
Example #10
0
 public override void SetObjectUri(OpenSocialActivity openSocialActivity, SnesActivityData eventData)
 {
     Contents.ObjectUri = openSocialActivity.ObjectUri;
 }
Example #11
0
 public override void SetObjectDescription(OpenSocialActivity openSocialActivity, SnesActivityData eventData)
 {
     Contents.ObjectDescription = openSocialActivity.ObjectDescription;
 }
Example #12
0
 public override void SetObjectTitle(OpenSocialActivity openSocialActivity, SnesActivityData eventData)
 {
     Contents.ObjectTitle = openSocialActivity.ObjectTitle;
 }
Example #13
0
 public abstract void SetObjectUri(OpenSocialActivity openSocialActivity, SnesActivityData activityData);
Example #14
0
 public abstract void SetObjectDescription(OpenSocialActivity openSocialActivity, SnesActivityData activityData);
Example #15
0
 public abstract void SetTitle(OpenSocialActivity openSocialActivity, SnesActivityData activityData);