Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erase the CONTENT CREATED activity once an EDITED_CONTENT comes #2122

Open
brecke opened this issue Apr 22, 2020 · 0 comments
Open

Erase the CONTENT CREATED activity once an EDITED_CONTENT comes #2122

brecke opened this issue Apr 22, 2020 · 0 comments

Comments

@brecke
Copy link
Member

brecke commented Apr 22, 2020

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);
      });
    });
  }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant