How to use activity-streams - 2 common examples

To help you get started, we’ve selected a few activity-streams examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sockethub / sockethub / src / validate.ts View on Github external
/**
 * responsible for handling the validation and expansion (when applicable) of all incoming objects
 */
import tv4 from 'tv4';
import debug from 'debug';
import URI from 'urijs';
import ActivityStreams from 'activity-streams';
import * as SockethubSchemas from 'sockethub-schemas';

import init from './bootstrap/init';
import config from './config';

const activity = ActivityStreams(config.get('activity-streams:opts')),
      log = debug('sockethub:validate');

// load sockethub-activity-stream schema and register it with tv4
// http://sockethub.org/schemas/v0/activity-stream#
tv4.addSchema(SockethubSchemas.ActivityStream.id, SockethubSchemas.ActivityStream);
// load sockethub-activity-object schema and register it with tv4
// http://sockethub.org/schemas/v0/activity-object#
tv4.addSchema(SockethubSchemas.ActivityObject.id, SockethubSchemas.ActivityObject);

// educated guess on what the displayName is, if it's not defined
// since we know the @id is a URI, we prioritize by username, then fragment (no case yet for path)
function ensureDisplayName(msg) {
  if ((msg['@id']) && (! msg.displayName)) {
    const uri = new URI(msg['@id']);
    return uri.username() || getUriFragment(uri) || uri.path();
  }
github sockethub / sockethub / src / sockethub.ts View on Github external
import kue from 'kue';
import Store from 'secure-store-redis';
import ActivityStreams from 'activity-streams';

import config from './config';
import crypto from './crypto';
import init from './bootstrap/init';
import Middleware from './middleware';
import resourceManager from './resource-manager';
import services from './services';
import validate from './validate';
import Worker from './worker';
import SharedResources from "./shared-resources";

const log = debug('sockethub:core  '),
      activity = ActivityStreams(config.get('activity-streams:opts'));

interface ActivityObject {
  actor?: {
    '@id'?: string;
  }
  error?: any;
}

class Sockethub {
  private readonly parentId: string;
  private readonly parentSecret1: string;
  private readonly parentSecret2: string;
  counter: number;
  platforms: Map;
  status: boolean;
  queue: any;

activity-streams

A simple tool to facilitate handling and referencing activity streams without unnecessary verbosity

LGPL-3.0
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis

Popular activity-streams functions