Erase the `CONTENT CREATED` activity once an `EDITED_CONTENT` comes
Opened this issue · 0 comments
brecke commented
This is a result of #1967
What I'd like to do is to erase the created
event for an etherpad/ethercalc document once the correspondent edited
event comes. Right now this is get:
- User creates etherpad/ethercalc -> CREATED activity without preview
- User edits etherpad/ethercalc -> EDITED activity with preview
This would be something along the lines of:
ActivityAPI.postActivity(ctx, activitySeed, err => {
/**
* After we post a new EDITED activity we are going to erase the CREATED one
* This is because it's mostly useless. The CREATED activity is only useful for other
* people to be able to join and collaborate on a document. Once that is published
* the first time, the EDITED activity is prevalent and will also have a preview
* (unlike the CREATED activity)
*/
const activityStreamId = `${activitySeed.actorResource.resourceId}#activity`;
// get 10 most recent activities
const startFromNewest = null;
getActivities(activityStreamId, startFromNewest, 10, (err, mostRecentActivities) => {
// then make sure we pick the ones where `oae:activityType:"content-create"`
forEach(eachActivity => {
// when we find the one that corresponds to the same `objectResource`
const isContentCreated = activity => equals('content-create', path(['oae:activityType'], activity));
const isTheSameContent = activity => equals(path(['object', 'id'], activity), activitySeed.objectResource.id);
if (both(isContentCreated, isTheSameContent)(eachActivity)) {
console.log('ERASE THIS GUY');
// then erase it
}
}, mostRecentActivities);
});
});
}
);