Skip to content

Unable to use the GetActivities response for actor in UpdateActivity #629

@karthikkasturisfx

Description

@karthikkasturisfx

The client.feed.addActivity's NewActivity parameter type allows actor to be an object

stream-js/src/feed.ts

Lines 87 to 94 in bffb182

export type NewActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> =
StreamFeedGenerics['activityType'] &
BaseActivity & {
actor: string | StreamUser;
object: string | unknown;
foreign_id?: string;
time?: string;
};

Here it allows the actor to be either a string or a StreamUser object

But when we try to update the activity, the client.updateActivity's activity parameter does not allow actor to be an object.

stream-js/src/feed.ts

Lines 96 to 103 in bffb182

export type UpdateActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> =
StreamFeedGenerics['activityType'] &
BaseActivity & {
actor: string;
foreign_id: string;
object: string | unknown;
time: string;
};

This is an issue because when we use client.feed.getActivity, the activities can be returned as enriched stream users. If we wish to update activities, we can not update the item directly

Image Image

Sample code in text:

import {StreamClient} from 'getstream';

const client = new StreamClient('STREAM_KEY', 'STREAM_SECRET');


const data = await client.getActivities({ids: ['id1']});


const activities = data.results;

activities.forEach(activity => {
    activity.title = 'Updated Title';
});

client.updateActivities(activities);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions