MCPcopy Create free account
hub / github.com/GetStream/stream-js / getActivities

Method getActivities

src/client.ts:849–902  ·  view source on GitHub ↗

* Retrieve activities by ID or foreign_id and time * @link https://getstream.io/activity-feeds/docs/node/add_many_activities/?language=js#batch-get-activities-by-id * @param {object} params object containing either the list of activity IDs as {ids: ['...', ...]} or foreign_ids and time as {fo

({
    ids,
    foreignIDTimes,
    ...params
  }: EnrichOptions & {
    foreignIDTimes?: ForeignIDTimes[];
    ids?: string[];
    reactions?: Record<string, boolean>;
    user_id?: string;
  })

Source from the content-addressed store, hash-verified

847 * @return {Promise<GetActivitiesAPIResponse>}
848 */
849 getActivities({
850 ids,
851 foreignIDTimes,
852 ...params
853 }: EnrichOptions & {
854 foreignIDTimes?: ForeignIDTimes[];
855 ids?: string[];
856 reactions?: Record<string, boolean>;
857 user_id?: string;
858 }) {
859 const extraParams: { foreign_ids?: string; ids?: string; timestamps?: string } = {};
860
861 if (ids) {
862 if (!(ids instanceof Array)) {
863 throw new TypeError('The ids argument should be an Array');
864 }
865 extraParams.ids = ids.join(',');
866 } else if (foreignIDTimes) {
867 if (!(foreignIDTimes instanceof Array)) {
868 throw new TypeError('The foreignIDTimes argument should be an Array');
869 }
870 const foreignIDs: string[] = [];
871 const timestamps: (Date | string)[] = [];
872 foreignIDTimes.forEach((fidTime) => {
873 if (!(fidTime instanceof Object)) {
874 throw new TypeError('foreignIDTimes elements should be Objects');
875 }
876 foreignIDs.push((fidTime as { foreign_id: string }).foreign_id || (fidTime as { foreignID: string }).foreignID);
877 timestamps.push(fidTime.time);
878 });
879
880 extraParams.foreign_ids = foreignIDs.join(',');
881 extraParams.timestamps = timestamps.join(',');
882 } else {
883 throw new TypeError('Missing ids or foreignIDTimes params');
884 }
885
886 let token = this.userToken as string;
887 if (this.usingApiSecret) {
888 token = JWTScopeToken(this.apiSecret as string, 'activities', '*', {
889 feedId: '*',
890 expireTokens: this.expireTokens,
891 });
892 }
893
894 this.replaceReactionOptions(params);
895 const path = this.shouldUseEnrichEndpoint(params) ? 'enrich/activities/' : 'activities/';
896
897 return this.get<GetActivitiesAPIResponse<StreamFeedGenerics>>({
898 url: path,
899 qs: { ...params, ...extraParams },
900 token,
901 });
902 }
903
904 getOrCreateToken() {
905 if (!this._getOrCreateToken) {

Callers 9

activities.jsFile · 0.80
client_test.jsFile · 0.80
test.tsFile · 0.80
isGoingToThrow1Function · 0.80
isGoingToThrow2Function · 0.80
isGoingToThrow3Function · 0.80
isGoingToThrow4Function · 0.80
isNotGoingToThrowFunction · 0.80
client_test.jsFile · 0.80

Calls 3

getMethod · 0.95
JWTScopeTokenFunction · 0.90

Tested by

no test coverage detected