Skip to content
This repository was archived by the owner on Jan 15, 2022. It is now read-only.

Commit

Permalink
WIKI-1450 : Wiki's activities update (#449)
Browse files Browse the repository at this point in the history
When we update a wiki page and save without the option "activity stream", the former wiki's activity is put at the top of the stream.
The cause of this behavior is the update of the date of the Activity Stream Item.
This update might be done only if the content of the activity has changed and the updatedDate is different from that of the existing activity
  • Loading branch information
abeji authored Jan 31, 2019
1 parent cfa8142 commit 5bab341
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1021,9 +1021,9 @@ public void updateActivity(ExoSocialActivity existingActivity) throws ActivitySt
// update comment
updatedActivity.setUpdatedDate(new Date());
}
//only raise the activity in stream when activity message updated
if (existingActivity.getTitle() != null &&
existingActivity.getTitle().equals(existingActivity.getTitle())) {
// only raise the activity in stream when activity date updated
if (existingActivity.getUpdated() != null && updatedActivity.getUpdatedDate() != null
&& existingActivity.getUpdated().getTime() != updatedActivity.getUpdatedDate().getTime()) {
processActivityStreamUpdatedTime(updatedActivity);
}
//create or remove liker if exist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@
*/
package org.exoplatform.social.core.jpa.storage;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.social.core.activity.model.ExoSocialActivity;
import org.exoplatform.social.core.activity.model.ExoSocialActivityImpl;
import org.exoplatform.social.core.identity.model.Identity;
import org.exoplatform.social.core.identity.provider.SpaceIdentityProvider;
import org.exoplatform.social.core.jpa.storage.dao.StreamItemDAO;
import org.exoplatform.social.core.jpa.storage.entity.StreamItemEntity;
import org.exoplatform.social.core.jpa.test.AbstractCoreTest;
import org.exoplatform.social.core.jpa.test.MaxQueryNumber;
import org.exoplatform.social.core.jpa.test.QueryNumberTest;
Expand All @@ -31,27 +38,26 @@
import org.exoplatform.social.core.space.spi.SpaceService;
import org.exoplatform.social.core.storage.api.IdentityStorage;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@QueryNumberTest
public class RDBMSActivityStorageImplTest extends AbstractCoreTest {

private IdentityStorage identityStorage;

private StreamItemDAO streamItemDAO;

private List<ExoSocialActivity> tearDownActivityList;

private Identity rootIdentity;
private Identity johnIdentity;
private Identity maryIdentity;
private Identity demoIdentity;


@Override
protected void setUp() throws Exception {
super.setUp();
identityStorage = getService(IdentityStorage.class);
streamItemDAO = getService(StreamItemDAO.class);

assertNotNull(identityStorage);
assertNotNull(activityStorage);
Expand Down Expand Up @@ -106,15 +112,22 @@ public void testSaveActivity() {
public void testUpdateActivity() {
ExoSocialActivity activity = createActivity(1);
//
activityStorage.saveActivity(demoIdentity, activity);
ExoSocialActivity activityCreated = activityStorage.saveActivity(demoIdentity, activity);
List<StreamItemEntity> streamItems = streamItemDAO.findStreamItemByActivityId(Long.parseLong(activityCreated.getId()));

activity.setTitle("Title after updated");
activityCreated.setTitle("Title after updated");

//update
activityStorage.updateActivity(activity);

activityStorage.updateActivity(activityCreated);

ExoSocialActivity res = activityStorage.getActivity(activity.getId());
// Check that stream Item update date is not modified

List<StreamItemEntity> streamItemsRes = streamItemDAO.findStreamItemByActivityId(Long.parseLong(activityCreated.getId()));

assertEquals(streamItemsRes.get(0).getUpdatedDate(),streamItems.get(0).getUpdatedDate());

assertEquals("Title after updated", res.getTitle());
//
tearDownActivityList.add(activity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,10 @@ public List<ExoSocialActivity> getOlderComments(
public SortedSet<ActivityProcessor> getActivityProcessors();

/**
* Updates an existing activity.
* Updates an existing activity. If the updatedDate is different than the
* previous one, it is updated and the activity is moved up in the activity
* stream, otherwise the activity is updated without being moved in the
* stream.
*
* @param existingActivity
* @throws ActivityStorageException
Expand Down

0 comments on commit 5bab341

Please sign in to comment.