Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. public ThreadSummaryInfo(String title, ConnectApi.FeedElement fe, Integer num_likes, Integer num_comments){
  2. this.title = title;
  3. this.body = fe.body.text;
  4. this.threadId = fe.Id;
  5. this.dtPosted = fe.relativeCreatedDate;
  6.  
  7. ConnectApi.FeedItem feedItem = (ConnectApi.FeedItem) fe;
  8. ConnectApi.ActorWithId actorObj = (ConnectApi.ActorWithId)feedItem.actor;
  9. this.author = actorObj.Name;
  10. Id authorId = actorObj.Id;
  11. ConnectApi.Photo authorPhotoInfo = ConnectApi.UserProfiles.getPhoto(getGELSCommunityId(),authorId);
  12. this.authorMotif = authorPhotoInfo.fullEmailPhotoUrl;
  13.  
  14. this.numLikes = num_likes;
  15. this.numComments = num_comments;
  16.  
  17. this.comments = new List<GELSUtility.ThreadCommentInfo>();
  18. this.comments_sorted = GELSUtility.FeedCommentInfo(fe.Id);
  19.  
  20. ConnectApi.FeedElement feedDetails = ConnectApi.ChatterFeeds.getFeedElement(getGELSCommunityId(),threadId,3,10);
  21. if(feedDetails.capabilities.questionAndAnswers != null) {
  22. ConnectApi.QuestionAndAnswersCapability q = feedDetails.capabilities.questionAndAnswers;
  23. if(q.bestAnswer!= null)this.hasVerifiedAnswer = true;
  24. else this.hasVerifiedAnswer = false;
  25. }
  26. //this.hasVerifiedAnswer = false;
  27. this.relatedTopics = new List<String>();
  28. this.threadPageURL = retrieveGELSCommunityInfo().siteURL + '/s/thread?c=' + this.threadId;
  29. this.isSOQL=true;
  30. this.mainTopicInfoStr = '';
  31.  
  32. if(fe.capabilities.chatterLikes != null){
  33. ConnectApi.ChatterLikesCapability liked = fe.capabilities.chatterLikes;
  34. system.debug('Thread like data = '+liked);
  35. this.likedByCurrUser = liked.isLikedByCurrentUser;
  36. }
  37.  
  38. this.parentTopicName = '';
  39. this.grandParentTopicName = '';
  40. }
  41.  
  42. global class ThreadCommentInfo implements Comparable {
  43. public String commentBody;
  44. public String author;
  45. public String authorMotif;
  46. public String authorAboutMe;
  47. public String dtPosted = 'Today';//If current user is a member or not
  48. public String commentId;
  49. public Integer numLikes = 0;
  50. public Boolean isVerifiedAnswer = false;
  51. public Boolean isLikedByCurrUser;
  52.  
  53. global ThreadCommentInfo(ConnectApi.Comment comment){
  54. system.debug('@@ThreadCommentInfo');
  55. 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.
  56.  
  57. ConnectApi.User authorInfo = comment.user;
  58. this.author = authorInfo.displayName;
  59. Id authorId = comment.user.Id;
  60.  
  61. this.authorAboutMe = authorInfo.additionalLabel;
  62. ConnectApi.Photo authorPhotoInfo = ConnectApi.UserProfiles.getPhoto(getGELSCommunityId(),authorId);
  63. this.authorMotif = authorPhotoInfo.fullEmailPhotoUrl;
  64. this.dtPosted = comment.relativeCreatedDate;
  65. this.commentId = comment.Id;
  66. this.numlikes = comment.likes.total;
  67. if(comment.myLike == null){
  68. this.isLikedByCurrUser = false;
  69. }else{
  70. this.isLikedByCurrUser = true;
  71. }
  72. }
  73.  
  74. 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. */
  75.  
  76. GELSUtility.ThreadSummaryInfo th = New GELSUtility.ThreadSummaryInfo('NewTestThread', feedsList[0], 5, 2);
  77.  
  78. connectApi.Comment cmnt = New connectApi.Comment();
  79.  
  80. GELSUtility.ThreadCommentInfo tcinf = New GELSUtility.ThreadCommentInfo(cmnt);
  81. enter code here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement