Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

News stories going in but nothing coming out

Vote:
0

Hi,

I have followed the community documentation regarding news feeds.

I have set up the actions on application initialisation using the following code.

NewsFeedAction publishAction = NewsFeedHandler.Instance.GetAction(NewsFeedActions.PublishAction);
if (publishAction == null)
{
   publishAction = new NewsFeedAction(NewsFeedActions.PublishAction, NewsFeedActionCapability.None);
   NewsFeedHandler.Instance.AddAction(publishAction);
}

To insert a news story the code used is...

Look look = e.Object as Look;
if(look != null)
{
    IAuthor author = look.Author;
    NewsFeedAction publishedALook = NewsFeedHandler.Instance.GetAction(NewsFeedActions.PublishAction);
    NewsFeedStory story = new NewsFeedStory(publishedALook, author, null, look);
    story.Status = EntityStatus.Approved;
    story.ActionDate = DateTime.Now;
    NewsFeedHandler.Instance.AddStory(story);

}

The story goes into the database and I try to retrieve the stories for users as follows

NewsFeedStoryCollection newsFeedStoryCollection = NewsFeedHandler.Instance.GetNewsFeedStories(type, EntityStatus.Approved, user, null, fromDate, toDate, pageNumber, pageSize, out totalItems);

The user is an IUser, the from date is now - 5 years and the the toDate is not + 5 years.

I noticed in the relate plus templates that news feeds and mini feeds are setup for each user on registration, although this is not specified as a requirement in the comminity documentation for newsfeeds.

So I retrospectively set up news feeds and mini feeds for each of our users using the following code...

foreach (int id in ids)
            {
                IUser user = SecurityHandler.Instance.GetUser(id);

                // create the user's newsfeed and minifeed and set its access rights.
                NewsFeed newsFeed = new NewsFeed(NewsFeedType.NewsFeed, user);
                newsFeed = NewsFeedHandler.Instance.AddNewsFeed(newsFeed);

                NewsFeedAccessRights nfAccessRights = new NewsFeedAccessRights()
                {
                    Read = true,
                    Modify = true,
                    Remove = true,
                    Categorize = true,
                    Comment = true,
                    Rate = true,
                    Tag = true
                };

                EntitySecurityHandler.Instance.SetAccessRights(newsFeed, user, nfAccessRights);

                NewsFeed miniFeed = new NewsFeed(NewsFeedType.MiniFeed, user);
                miniFeed = NewsFeedHandler.Instance.AddNewsFeed(miniFeed);

                NewsFeedAccessRights miniFeedAccessRights = new NewsFeedAccessRights()
                {
                    Read = true,
                    Modify = true,
                    Remove = true,
                    Categorize = true,
                    Comment = true,
                    Rate = true,
                    Tag = true
                };

                EntitySecurityHandler.Instance.SetAccessRights(miniFeed, user, miniFeedAccessRights);
            }

I then cleared all stories from the db and performed some actions that trigger news stories being insterted into the system.

I still get nothing coming out.

Any help with this would be much appreciated.

 

#54236
Oct 06, 2011 10:59
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.