Foren
Friends not added or accepted
fastbob fastbob, geändert vor 12 Jahren.
Friends not added or accepted
Regular Member Beiträge: 221 Beitrittsdatum: 16.05.05 Neueste Beiträge
In one of my portlets I'd like to establish a friend relationship between two users. In addition, I'd like to automatically accept the request so the users don't need to accept the request
Starting with Rich Sezov's excellent book, I added the following code:
Unfortunately, although no exceptions are thrown, the users are never marked as friends. What am I doing wrong? Thanks.
Starting with Rich Sezov's excellent book, I added the following code:
com.liferay.portlet.social.model.SocialRequest request =
SocialRequestLocalServiceUtil.addRequest( userId, 0, User.class.getName(),
userId, SocialRelationConstants.TYPE_BI_COWORKER, StringPool.BLANK, requester);
// Confirm this request on behalf of the receiver
request.setStatus( SocialRequestConstants.STATUS_CONFIRM);
SocialRequestLocalServiceUtil.updateSocialRequest( request);
Unfortunately, although no exceptions are thrown, the users are never marked as friends. What am I doing wrong? Thanks.
jelmer kuperus, geändert vor 12 Jahren.
RE: Friends not added or accepted
Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
I believe you need to call
SocialRelationLocalServiceUtil.addRelation(request.getUserId(), request.getReceiverUserId(), SocialRelationConstants. TYPE_BI_COWORKER);
fastbob fastbob, geändert vor 12 Jahren.
RE: Friends not added or accepted
Regular Member Beiträge: 221 Beitrittsdatum: 16.05.05 Neueste Beiträge
Thanks for the suggestion. I tried this call and it seems to work when I get a list of friends via:
But these friends do not show up in the LR friends portlet. Suggestions?
List<user> relations = UserLocalServiceUtil.getSocialUsers( userId, start, end, new UserLastNameComparator(true));
</user>
But these friends do not show up in the LR friends portlet. Suggestions?
jelmer kuperus, geändert vor 12 Jahren.
RE: Friends not added or accepted
Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
You mean the social networking portlet ?
That portlet will only list relations of type SocialRelationConstants.TYPE_BI_FRIEND
You are establishing a co-worker relationship, not a friend relationship
That portlet will only list relations of type SocialRelationConstants.TYPE_BI_FRIEND
You are establishing a co-worker relationship, not a friend relationship
fastbob fastbob, geändert vor 12 Jahren.
RE: Friends not added or accepted
Regular Member Beiträge: 221 Beitrittsdatum: 16.05.05 Neueste Beiträge
Yes, the social networking portlet. I was under the impression from Rich's book that the portlet uses TYPE_BI_COWORKER, although perusing the 6.0.6 code I couldn't determine what was actually used (I certainly could have missed it). Anyway, thanks for your help.