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

Method activitiesPartialUpdate

src/client.ts:1040–1077  ·  view source on GitHub ↗

* Update multiple activities with partial operations. * @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js&q=partial+#activity-partial-update * @param {ActivityPartialChanges []} changes array containing the changesets to be applied. Every cha

(changes: ActivityPartialChanges<StreamFeedGenerics>[])

Source from the content-addressed store, hash-verified

1038 * ])
1039 */
1040 activitiesPartialUpdate(changes: ActivityPartialChanges<StreamFeedGenerics>[]) {
1041 if (!(changes instanceof Array)) {
1042 throw new TypeError('changes should be an Array');
1043 }
1044 changes.forEach(
1045 (item: ActivityPartialChanges<StreamFeedGenerics> & { foreign_id?: string; foreignID?: string }) => {
1046 if (!(item instanceof Object)) {
1047 throw new TypeError(`changeset should be and Object`);
1048 }
1049 if (item.foreignID) {
1050 item.foreign_id = item.foreignID;
1051 }
1052 if (item.id === undefined && (item.foreign_id === undefined || item.time === undefined)) {
1053 throw new TypeError('missing id or foreign_id and time');
1054 }
1055 if (item.set && !(item.set instanceof Object)) {
1056 throw new TypeError('set field should be an Object');
1057 }
1058 if (item.unset && !(item.unset instanceof Array)) {
1059 throw new TypeError('unset field should be an Array');
1060 }
1061 },
1062 );
1063
1064 let token = this.userToken as string;
1065 if (this.usingApiSecret) {
1066 token = JWTScopeToken(this.apiSecret as string, 'activities', '*', {
1067 feedId: '*',
1068 expireTokens: this.expireTokens,
1069 });
1070 }
1071
1072 return this.post<APIResponse & { activities: Activity<StreamFeedGenerics>[] }>({
1073 url: 'activity/',
1074 body: { changes },
1075 token,
1076 });
1077 }
1078
1079 /**
1080 * Flag a user for moderation

Callers 12

activityPartialUpdateMethod · 0.95
activities.jsFile · 0.80
test.tsFile · 0.80
isGoingToThrow1Function · 0.80
isGoingToThrow2Function · 0.80
isGoingToThrow3Function · 0.80
isGoingToThrow4Function · 0.80
isGoingToThrow5Function · 0.80
isGoingToThrow6Function · 0.80
isGoingToThrow7Function · 0.80
isGoingToThrow8Function · 0.80
client_test.jsFile · 0.80

Calls 2

postMethod · 0.95
JWTScopeTokenFunction · 0.90

Tested by

no test coverage detected