SaaS CMS has officially launched! Learn more now.

Understanding Comments

I'm working with comments on news items.
I'm adding the comments like this:

Comment comment = new Comment(EntityReference, string.Empty, commentBody, new UserAuthor(CurrentUser));

I remove comments roughly like this:

IComment commentToRemove = CommentHandler.Instance.GetComment(commentID);

Now for some reason, the comments also appear in the news list. I'm thinking that it should be possible somehow to filter the comments away somehow.
What's interesting is that when I delete the comments, they are deleted from the comments list for that item, *but* they still exists as news items.

What is EpiServer.Common.Comments and how are they stored?
Dec 08, 2011 11:55

The news items you talk about, are they entries in the club news blog? How do you mean the comments appear as news items?

Dec 08, 2011 12:27

They are coming from NewsFeedFilteringManager.GetNewsFeedStories.

Dec 08, 2011 14:21

Well we settled this but I'll post the solution here in case someone else has similar problems and finds the thread.

The NewsFeed shows "Stories" that can be created in the Community framework when something happens, for example when someone posts a comment. This is handled by adding an event handler to the CommentHandler.CommentAdded event etc. In the event handler a separate NewsFeedStory object is created and committed to the database. Because the NewsFeed shows the NewsFeedStory and not the Comment it can remain even if the Comment is removed.

To fix this, the class rendering the NewsFeed should check if the Comment corresponding to the NewsFeedStory still exists and has not been hard or soft removed (it's status set to Removed). NewsFeedStories can have Actors and Targets and Actors can have Attachments. If the event handler for the CommentAdded event is implemented in a good way it will add the Comment itself as a reference to the NewsFeedStory, for example as an Attachment to one of the Actors. This means that when the NewsFeedStory is to be rendered it is possible to get a reference to the Comment and see if it still exists and doesn't have status removed, in which case you can choose to not render the story.

Dec 08, 2011 14:52
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.