Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ThreadSummaryInfo(String title, ConnectApi.FeedElement fe, Integer num_likes, Integer num_comments){
- this.title = title;
- this.body = fe.body.text;
- this.threadId = fe.Id;
- this.dtPosted = fe.relativeCreatedDate;
- ConnectApi.FeedItem feedItem = (ConnectApi.FeedItem) fe;
- ConnectApi.ActorWithId actorObj = (ConnectApi.ActorWithId)feedItem.actor;
- this.author = actorObj.Name;
- Id authorId = actorObj.Id;
- ConnectApi.Photo authorPhotoInfo = ConnectApi.UserProfiles.getPhoto(getGELSCommunityId(),authorId);
- this.authorMotif = authorPhotoInfo.fullEmailPhotoUrl;
- this.numLikes = num_likes;
- this.numComments = num_comments;
- this.comments = new List<GELSUtility.ThreadCommentInfo>();
- this.comments_sorted = GELSUtility.FeedCommentInfo(fe.Id);
- ConnectApi.FeedElement feedDetails = ConnectApi.ChatterFeeds.getFeedElement(getGELSCommunityId(),threadId,3,10);
- if(feedDetails.capabilities.questionAndAnswers != null) {
- ConnectApi.QuestionAndAnswersCapability q = feedDetails.capabilities.questionAndAnswers;
- if(q.bestAnswer!= null)this.hasVerifiedAnswer = true;
- else this.hasVerifiedAnswer = false;
- }
- //this.hasVerifiedAnswer = false;
- this.relatedTopics = new List<String>();
- this.threadPageURL = retrieveGELSCommunityInfo().siteURL + '/s/thread?c=' + this.threadId;
- this.isSOQL=true;
- this.mainTopicInfoStr = '';
- if(fe.capabilities.chatterLikes != null){
- ConnectApi.ChatterLikesCapability liked = fe.capabilities.chatterLikes;
- system.debug('Thread like data = '+liked);
- this.likedByCurrUser = liked.isLikedByCurrentUser;
- }
- this.parentTopicName = '';
- this.grandParentTopicName = '';
- }
- global class ThreadCommentInfo implements Comparable {
- public String commentBody;
- public String author;
- public String authorMotif;
- public String authorAboutMe;
- public String dtPosted = 'Today';//If current user is a member or not
- public String commentId;
- public Integer numLikes = 0;
- public Boolean isVerifiedAnswer = false;
- public Boolean isLikedByCurrUser;
- global ThreadCommentInfo(ConnectApi.Comment comment){
- system.debug('@@ThreadCommentInfo');
- this.commentBody = comment.body.text; //Test method covers this much. After this point, nothing is covered because I have not initialised values for comment.body etc.
- ConnectApi.User authorInfo = comment.user;
- this.author = authorInfo.displayName;
- Id authorId = comment.user.Id;
- this.authorAboutMe = authorInfo.additionalLabel;
- ConnectApi.Photo authorPhotoInfo = ConnectApi.UserProfiles.getPhoto(getGELSCommunityId(),authorId);
- this.authorMotif = authorPhotoInfo.fullEmailPhotoUrl;
- this.dtPosted = comment.relativeCreatedDate;
- this.commentId = comment.Id;
- this.numlikes = comment.likes.total;
- if(comment.myLike == null){
- this.isLikedByCurrUser = false;
- }else{
- this.isLikedByCurrUser = true;
- }
- }
- List<ConnectApi.FeedElement> feedsList = New List<ConnectApi.FeedElement>(); /* Unabe to instantiate ConnectApi.FeedElement here. It does not have a default constructor. It says that constructor is missing. How do I even get to know the parameters that the constructor expects. */
- GELSUtility.ThreadSummaryInfo th = New GELSUtility.ThreadSummaryInfo('NewTestThread', feedsList[0], 5, 2);
- connectApi.Comment cmnt = New connectApi.Comment();
- GELSUtility.ThreadCommentInfo tcinf = New GELSUtility.ThreadCommentInfo(cmnt);
- enter code here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement