Giter Club home page Giter Club logo

stream-java's Introduction

Official Java SDK for Stream Feeds

build

Official Java API client for Stream Feeds, a web service for building scalable newsfeeds and activity streams.
Explore the docs »

JavaDoc · Report Bug · Request Feature

📝 About Stream

You can sign up for a Stream account at our Get Started page.

You can use this library to access feeds API endpoints server-side.

For the client-side integrations (web and mobile) have a look at the JavaScript, iOS and Android SDK libraries (docs).

💡 Note: this is a library for the Feeds product. The Chat SDKs can be found here.

⚙️ Installation

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.getstream.client</groupId>
    <artifactId>stream-java</artifactId>
    <version>${stream_version}</version>
</dependency>

or in your build.gradle:

implementation 'io.getstream.client:stream-java:$stream_version'

In case you want to download the artifact and put it manually into your project, you can download it from here.

Snapshots of the development version are available in Sonatype snapshots repository.

💡This API Client project requires Java SE 7.

🙋 FAQ

  1. Is Android supported?

Yes. Use client for your backend and use CloudClient for your mobile application.

  1. Cannot construct an instance of io.getstream.core.models.*, a model object in android. What is the problem?

If you're using proguard, ensure having following: -keep class io.getstream.core.models.** { *; }

Additionally, we're using Jackson JSON processor and see their definitions too unless you're already using it.

📚 Full documentation

Documentation for this Java client are available at the Stream website.

For examples have a look here.

Docs are available on GetStream.io.

JavaDoc is available here.

🧪 Building & Testing

Run gradlew test to execute integration tests

✍️ Contributing

We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our Contributor License Agreement (CLA) first. See our license file for more details.

🧑‍💻 We are hiring!

We've recently closed a $38 million Series B funding round and we keep actively growing. Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.

Check out our current openings and apply via Stream's website.

stream-java's People

Contributors

dwightgunning avatar ferhatelmas avatar flosketch avatar github-actions[bot] avatar itsmeadi avatar jcminarro avatar kevcodez avatar leandroborgesferreira avatar marco-ulge avatar methodlevelanalyzer avatar nator333 avatar nekuromento avatar nouhouari avatar peterdeme avatar sirio7g avatar tbarbugli avatar tschellenbach avatar ude avatar xernobyl avatar yaziine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stream-java's Issues

Using with Java 8

Hello!

The doc states:

💡This API Client project requires Java SE 7.

However, it seems that the jar from maven won't work for Java < 11, importing any io.getstream class causes compilation to fail (I've tried with recent and old library versions with no success).

bad class file: /.../maven2/io/getstream/stream-chat-java/1.0.0/stream-chat-java-1.0.0.jar(io/getstream/chat/java/exceptions/StreamException.class)
    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

Better GraalVM support

While migrating an application to GraalVM I found several issues with the GetStream Java client.

I had to manually include the stream-java2.info file into the binary. Also I had to register several classes for reflection: io.getstream.core.models.serialization.DataDeserializer and 11 anonymous classes of io.getstream.core.Stream.

All these procedures took a lot of time to figure out. It would be great if you could solve them on the library side so that the clients wouldn't have to spend time resolving incompatibilities.

Own reactions are not filtered out correspondingly

Hi guys! I'm observing some weird behavior with ownReactions using the latest java client lib. For some reason all reactions are sown as my own reactions despite they're made by other users. Attaching a code snippet:

public static void main(String[] args)throws MalformedURLException, StreamException,ExecutionException, InterruptedException {
        var key = "";
        var secret = "";
        Client client =  Client.builder(key, secret).build();

        // lets say I follow Mark
        var userMark = client.flatFeed("user", "mark");
        var timeline = client.flatFeed("timeline", "me");
        timeline.follow(userMark).get();

        // Mark publishes some post
        var activity = Activity.builder()
            .actor("mark")
            .verb("publish")
            .object(String.join(":", "post", "mark_awesome"))
            .time(new Date())
            .build();
        var postId = userMark.addActivity(activity).thenApply(Activity::getID).get();

        // I, Mark and someone else liked that post
        var myReaction = new Reaction.Builder()
            .kind("like")
            .activityID(postId)
            .userID("me")
            .build();
        client.reactions().add("me", myReaction).get();

        var markReaction = new Reaction.Builder()
            .kind("like")
            .activityID(postId)
            .userID("mark")
            .build();
        client.reactions().add("mark", markReaction).get();

        var someFellowReaction = new Reaction.Builder()
            .kind("like")
            .activityID(postId)
            .userID("fellow")
            .build();
        client.reactions().add("fellow", someFellowReaction).get();

        // and finally I wanna see the post with a reactions assuming
        // that `own reactions` is gonna be one like I made
         var ownReactions = client.flatFeed("timeline", "me")
             .getEnrichedActivities(new Limit(1), new Offset(0),
                 new EnrichmentFlags().withRecentReactions().withOwnReactions().withReactionCounts())
             .thenApply(activities -> activities.stream().findFirst().get())
             .thenApply(EnrichedActivity::getOwnReactions).get();
         // expect to see one reaction instead of actual three
         System.out.println(ownReactions.get("like").size());
    }

The actual response I got:

[ 
   Reaction   { 
      id=c159d93e-18c2-4621-b43c-e39ba0799406,
      appID=null,
      kind=like,
      userID=fellow,
      activityID=d829d530-28c5-11ea-8080-800055dc4c6b,
      parent=,
      ownChildren=null,
      latestChildren={ 

      },
      childrenCounts={ 

      },
      userData=null,
      activityData={ 

      },
      extra={ 
         updated_at=2019-12-27T16:27:59.531212Z,
         created_at=2019-12-27T16:27:59.531212Z
      }
   },
   Reaction   { 
      id=4160a90d-01a5-4656-8c1c-776d26069f30,
      appID=null,
      kind=like,
      userID=mark,
      activityID=d829d530-28c5-11ea-8080-800055dc4c6b,
      parent=,
      ownChildren=null,
      latestChildren={ 

      },
      childrenCounts={ 

      },
      userData=null,
      activityData={ 

      },
      extra={ 
         updated_at=2019-12-27T16:27:59.391021Z,
         created_at=2019-12-27T16:27:59.391021Z
      }
   },
   Reaction   { 
      id=67e81610-3adb-4235-abe5-614e898d297b,
      appID=null,
      kind=like,
      userID=me,
      activityID=d829d530-28c5-11ea-8080-800055dc4c6b,
      parent=,
      ownChildren=null,
      latestChildren={ 

      },
      childrenCounts={ 

      },
      userData=null,
      activityData={ 

      },
      extra={ 
         updated_at=2019-12-27T16:27:59.235449Z,
         created_at=2019-12-27T16:27:59.235449Z
      }
   }
]

DateDeserialize for format 'yyyy-MM-dd'T'HH:mm:ss'

Hi,

Currently we are having exception for the stream-java ver 1.2.0. below is the exception details:

...
com.fasterxml.jackson.databind.JsonMappingException: Cannot parse input date 2016-11-24T11:17:17Z
 at [Source: buffer(okio.GzipSource@4c31ba7b).inputStream(); line: 1, column: 806] (through reference chain: io.getstream.client.model.beans.StreamResponse["results"]->java.util.ArrayList[5]->io.getstream.client.model.beans.FeedFollow["created_at"])
 at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:210)
 at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:177)
 at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1474)
 at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:258)
 at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
 at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
 at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:217)
 at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:25)
 at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:520)
 at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
 at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:256)
 at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
 at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3702)
 at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2791)
 at io.getstream.client.okhttp.repo.StreamRepositoryImpl.getFollowers(StreamRepositoryImpl.java:182)
 at io.getstream.client.model.feeds.BaseFeed.getFollowers(BaseFeed.java:121)
...

Those exception occurs when trying to getFollower which have dateTime (created_at) that doesn't have milliseconds, e.g : 2016-11-24T11:17:17Z .

any advice or help on how this should resolve?
Should it ignore the millisecond when doing deserialize on date?

Thank you,

M Nanda Rimansyah

Activity exists after being deleted

Hello, I am having an issue deleting an activity.

Let´s say I have an activity in the user feed and I try to delete it:

client.flatFeed(feed).removeActivityByID(activityId.getValue()).join();

Then if I try to check if the activity exists I get the activity back:

client.flatFeed(feed).getActivities(new Filter().idGreaterThanEqual(activityId.getValue())).join()

I get it as many times as I request it. But, if I repeat the process, I don't get the activity anymore.

Or if I request the feed activities without the filter it is not there and, if after that I repeat the request with the filter, I don't get it anymore.

client.flatFeed(feed).getActivities().join()

gz#12262

NotAllowedException: token contains an invalid number of segments (code = 17 status = 403)

I keep getting this error NotAllowedException: token contains an invalid number of segments (code = 17 status = 403) when trying to use this with Flutter via Android Kotlin. I am using JS and Firebase Functions as the backend.

`
const client = stream.connect(STREAM_API_KEY, STREAM_API_SECRET, STREAM_APP_ID);

    var make = await client.user(userId).getOrCreate({userId});
    const token = client.createUserToken(userId);
    console.log(make.id);
    console.log(token);
    return Promise.all([make]).then(() => {
        return {token, api: STREAM_API_KEY, appId: STREAM_APP_ID};
    });`

It does return the token but the issue remains.

automate maven central publication

let's automate as much as possible of the upload process to MC within Travis CI. If possible it would be great to have a way to completely automate that.

What's the difference between FlatActivityServiceImpl and UserActivityServiceImpl?

There are four built-in feed groups. So there are four different implementation:
FlatActivityServiceImpl,
AggregatedActivityServiceImpl,
UserActivityServiceImpl,
NotificationActivityServiceImpl.

But what's the difference between FlatActivityServiceImpl and UserActivityServiceImpl. I cannot see any difference from their implementations.

Wrong api call from getEnrichedCustomActivities

I want to use my custom enriched activity, and I tried to call getEnrichedCustomActivities, but it returns a list of activity data models.

I think it is because now this function is call getActivities api ([domain]/api/v1.0/feed/xxxx),
it should call getEnrichedActivities api ([domain]/api/v1.0/**enrich/**feed/xxxx), right?

updating user resets all other values for that user

Using update like so:

client.user("123").update(new Data()
        .set("bio", "pikachu")).join();

empties all other values for that particular user. So when updating 'bio' for a user, their 'name', 'gender' etc gets deleted.

As a workaround, fetching the user Data obj first, then updating the key's value in that Data obj, and updating user with the full Data obj works as expected.

refactor tests for unit testing

right now we only do integration tests, we should split tests into integration tests and unit tests. the release cycle should not run integration tests

extraField is null

I am add a like with this piece of code:

    val client = CloudClient.builder(API_KEY, token, user).build()
    val like = Reaction.Builder().kind("like").activityID(activityID).userID(user).extraField("extraUserID", userID).build()
    return client.reactions().add(user, like).get()

When I want to get it via:

fun createJsonWithReaction(r: Reaction): String {
    val rid = r.id
    val activityID = r.activityID
    val kind = r.kind
    val userID = r.userID
    val extraUserID = r.extra["extraUserID"]
    val text = r.extra["text"]
    return "{\"id\":\"$rid\", \"activityID\":\"$activityID\", \"kind\":\"$kind\", \"userID\":\"$userID\", \"extraUserID\":\"$extraUserID\", \"text\":\"$text\"}"
}

r.extra["extraUserID"] will be null

What is the probleme here?

How I could subscribe to changes like Javascript does

Hi everyone!

To be honest I see that you have a little docs outdated and some cases merged docs between clients, so thats why my question. For example in the docs you have the option for subscribe to changes from any notification feed, but it's only for javascript.

So I'd like to know if exist any way to listening flat feed changes? or to listening reactions, comments or those kind of changes? I know you have React Native component but all our core app is on Kotlin and java, so that's why need a native.

You have this:

Subscribe to realtime updates via API client

let notificationFeed = client.feed('notification', '1');

function callback(data) {
    console.log(data);
}

function successCallback() {
    console.log('now listening to changes in realtime');
}

function failCallback(data) {
    alert('something went wrong, check the console logs');
    console.log(data);
}

user1.subscribe(callback).then(successCallback, failCallback);

And

Subscribe to realtime updates using UMD script

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/getstream/dist/js_min/getstream.js">
</script>

<script type="text/javascript">
    var client = stream.connect('n6dqxby6gcfa', userToken, '49021');
    var notificationFeed = client.feed('notification', '1');

    function callback(data) {
        console.log(data);
    }

    function successCallback() {
        console.log('now listening to changes in realtime');
    }

    function failCallback(data) {
        alert('something went wrong, check the console logs');
        console.log(data);
    }

    notificationFeed.subscribe(callback).then(successCallback, failCallback);
</script>

Exist any way to implement with java?

Attribute "id" in data causes exception

In my android app, I am trying to retrieve some enriched activities from a feed, simply declared:
feed = client.notificationFeed("notification");

Then I retrieve the notification groups with:

try {
    ActivityMarker marker = new ActivityMarker();
    CompletableFuture<List<NotificationGroup<EnrichedActivity>>> future = feed.getEnrichedActivities(marker.allSeen());

    List<NotificationGroup<EnrichedActivity>> groups = future.get();

    // Do something with ´groups´

} catch (StreamException e) {
    callback.onResult(null); 
} catch (InterruptedException e) {
    e.printStackTrace();
} catch (ExecutionException e) {
    e.printStackTrace();
}

And then of course use groups.

For some users, it works flawlessly. Some others, an ExecutionException is caught:
java.util.concurrent.ExecutionException: com.fasterxml.jackson.databind.JsonMappingException: Key can't be named 'id' (through reference chain: java.util.ArrayList[6]->io.getstream.core.models.NotificationGroup["activities"]->java.util.ArrayList[0]->io.getstream.core.models.EnrichedActivity$Builder["actor"])

I then check how that activity's actor looks like and is something along these lines:

{ 
   "created_at":"2019-12-09T23:39:31.995179Z",
   "updated_at":"2019-12-09T23:39:31.995179Z",
   "id":"user-123456",
   "data":{ 
      "id":"user-123456",      <- Hey, here's a problem!
      "name":"My Name Here",
      "some_other_data":"here"
   }
}

Maybe id is a keyword, or maybe the actor gets flattened and there's a dupe. How can I get that activity anyway? I can totally get rid of that "id", I don't need that info. But how can I retrieve unflattened data, OR, "data" as a string, or some other workaround?

Test shouldn't perform call to backend

Currently, our tests are performing calls to our backend server and they need concrete creds/config to pass.
It is not the best approach, because if any of our tests fail, we can't be sure it is because the code we changed is breaking them, the network connection to our backend was not good, or the backend server is not working as expected just at the moment our tests are running.

To improve it we should provide some Mock Server (There are different libs that can help us like MockWebServer or WireMock) configuring the expected responses for every request our tests need to perform

InvalidOrMissingInputException : Missing Response json for the exception.

At times the Exception occurs with out response code.

io.getstream.client.exception.InvalidOrMissingInputException
    at io.getstream.client.apache.repo.handlers.StreamExceptionHandler.handleResponseCode(StreamExceptionHandler.java:73) ~[stormjar.jar:?]
    at io.getstream.client.apache.repo.StreamActivityRepository.handleResponseCode(StreamActivityRepository.java:266) ~[stormjar.jar:?]
    at io.getstream.client.apache.repo.StreamActivityRepository.addActivity(StreamActivityRepository.java:103) ~[stormjar.jar:?]
    at io.getstream.client.apache.repo.StreamRepositoryImpl.addActivity(StreamRepositoryImpl.java:199) ~[stormjar.jar:?]
    at io.getstream.client.service.AbstractActivityService.addActivity(AbstractActivityService.java:69) ~[stormjar.jar:?]
    at de.carbook.storm.activity.operation.ActivityOperation.handleLocationPredicitionTask(ActivityOperation.java:230) ~[stormjar.jar:?]
    at de.carbook.storm.activity.operation.ActivityOperation.handleCarbookBaseActivity(ActivityOperation.java:115) ~[stormjar.jar:?]
    at de.carbook.storm.activity.operation.ActivityOperation.handleActivity(ActivityOperation.java:73) ~[stormjar.jar:?]
    at de.carbook.storm.activity.extract.ActivityBolt.execute(ActivityBolt.java:89) [stormjar.jar:?]
    at backtype.storm.topology.BasicBoltExecutor.execute(BasicBoltExecutor.java:50) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485]
    at backtype.storm.daemon.executor$fn__4273$tuple_action_fn__4275.invoke(executor.clj:670) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485]
    at backtype.storm.daemon.executor$mk_task_receiver$fn__4196.invoke(executor.clj:426) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485]
    at backtype.storm.disruptor$clojure_handler$reify__3772.onEvent(disruptor.clj:58) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485]
    at backtype.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:125) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485]
    at backtype.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:99) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485]
    at backtype.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:80) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485]
    at backtype.storm.daemon.executor$fn__4273$fn__4286$fn__4337.invoke(executor.clj:808) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485]
    at backtype.storm.util$async_loop$fn__543.invoke(util.clj:475) [storm-core-0.10.0.2.3.4.0-3485.jar:0.10.0.2.3.4.0-3485]
    at clojure.lang.AFn.run(AFn.java:22) [clojure-1.6.0.jar:?]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_60]

Integration of getstream.io feeds not working in android

Client client = Client.builder(apikey, apikeySecret).build();
FlatFeed user = client.flatFeed("timeline", userId);
List response = user.getActivities().join();

I found Error where the ' user.getActivities().join()' code works and crashes,which is given below.

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoSuchMethodError: No static method encodeBase64URLSafeString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.jar)
at com.auth0.jwt.JWTCreator.sign(JWTCreator.java:330)
at com.auth0.jwt.JWTCreator.access$100(JWTCreator.java:24)
at com.auth0.jwt.JWTCreator$Builder.sign(JWTCreator.java:311)
at io.getstream.core.utils.Auth.buildBackendToken(Auth.java:135)
at io.getstream.core.utils.Auth.buildBackendToken(Auth.java:123)
at io.getstream.core.utils.Auth.buildFeedToken(Auth.java:60)
at io.getstream.client.Client.getActivities(Client.java:212)
at io.getstream.client.FlatFeed.getActivities(FlatFeed.java:51)
at io.getstream.client.FlatFeed.getActivities(FlatFeed.java:23)

there is no code to integrate appid and token which is created from the backend.can u give me a solution for this?

How to get all likes and who liked?

My add like function looks like this (kotlin)

private fun addLike(user: String, token: String, activityID: String) {
    val client = CloudClient.builder(API_KEY, token, user).build()
    val like = Reaction.Builder().kind("like").activityID(activityID).build()
    client.reactions().add(user, like).join()
}

and the read is:

private fun getActivitiesForTeam(user: String, token: String, team: String): List<EnrichedActivity> {
    val client = CloudClient.builder(API_KEY, token, user).build()
    return client.flatFeed(team, "messages")
            .getEnrichedActivities(Limit(25), EnrichmentFlags().withOwnReactions().withRecentReactions().withReactionCounts()).join()
}

When I got the latest_reactions_extra field this will be:

latest_reactions_extra {} // I think this will be the empty

or

latest_reactions_extra {like: {next: }} //this is the not empty? But why is it nullstring?

So how can I get the like count and the users who liked?

Also how can I delete that like? I got nothing like a 'reactionID' but the docs says it will be something called reactionID

Thanks

EDIT

private fun addLike(user: String, token: String, activityID: String) {
    val client = CloudClient.builder(API_KEY, token, user).build()
    val like = Reaction.Builder().kind("like").activityID(activityID).userID(user).build()
    client.reactions().add(user, like).get()
}

when I modified the addLike function to this, I got this:

latest_reactions_extra {like: {next: https://stream-io-api.com/api/v1.0/reaction/activity_id/34oijgiojiojgiojijoijoij-tgrgrtgrtgt/like/?id_lt=ergerg-01e1-4b73-b88d-regger&limit=5&withOwnChildren=false}}

What is this?

while create user its not showing on dashboard

CompletableFuture clientData=client
.user("12233").getOrCreate(new Data()
.set("name", "XYZ" )
.set("role", "user"));
LOGGER.info("Id {} , data {}, token {}",clientData.get().getID(),clientData.get().getData().toString(),client.frontendToken(userProfile.getUserId()));

gz#9185

Don't impersonate user with CloudClient

I'm using the CloudClient in an Android application. When I try to add something to a user's feed I get "Don't impersonate user" with this code:

        client = CloudClient
            .builder(credentials.apiKey, credentials.token, "jeff")
            .build()
        val feed = client.flatFeed("user")
        feed.addActivity(
            Activity
                .builder()
                .actor("jeff")
                .verb("post")
                .`object`(UUID.randomUUID().toString())
                .extraField("message", message)
                .build()
        ).join()

However, it seems to work fine if I prefix the user with SU: like so:

        client = CloudClient
            .builder(credentials.apiKey, credentials.token, "jeff")
            .build()
        val feed = client.flatFeed("user")
        feed.addActivity(
            Activity
                .builder()
                .actor("SU:jeff")
                .verb("post")
                .`object`(UUID.randomUUID().toString())
                .extraField("message", message)
                .build()
        ).join()

With the other libraries (Swift/JS/etc.) I don't have to do this. Am I doing something wrong? What's the significance of SU?

Thanks!

JWT token expiration

JWT tokens supports a withExpiresAt options see here

Is it possible to add support for this in as an extension or a similar method to https://github.com/GetStream/stream-java/blob/6645fce4d648c8c4e3ec97b5f38543a8f28d312f/src/main/java/io/getstream/core/utils/Auth.java#L115-L114 ?

I've also seen this option is available in stream clients in other lang (e.g. ruby)

We want to leverage this so that if a malicious user were to access the token, they won't always have access to notification data. The default of a never expiring token seems too lax.

Example code seems to be outdated

Example code in the repository stream-java/example/Example.java as well as code in Get Started section seems to be a little outdated. In both places Pagination class is used to limit amount of activities got with getActivities.

    List<Activity> response = jack.getActivities(new Pagination().limit(10)).join();

After brief examination of the repo it seems that Pagination class is no longer existing and examples should be updated.

I can't get messages sent to a channel using the java sdk.

Hello getstream, I am having a problem getting messages sent to a channel using the java sdk. When I call '.getMembers()', I get the list of members, but when I call '.getMessages()', it always returns an empty list even though there are messages in it.

Always close an http response

I am trying to track down a file descriptor leak, which so far empirically points to the getstream client as the only major infra change on those instances. I haven't identified directly, so am scanning over the code for possible causes.

One small nit is that this only closes the response if buildResponse does not fail. That can throw an IAE, among others. For peace of mind, it would be better to wrap all logic with a try-with-resources to ensure that the response is closed, rather than delay it and possibly leak, e.g. try (response) { ... }

public void onResponse(Call call, okhttp3.Response response) {
io.getstream.core.http.Response httpResponse = buildResponse(response);
try (InputStream ignored = httpResponse.getBody()) {
result.complete(httpResponse);
} catch (Exception e) {
result.completeExceptionally(e);
} finally {
response.body().close();
}

ownChildren for reactions is null

I have a feed and I'm implementing the logic add reactions to reactions (i.e. liking post comments).
When getting the coments for a certain post i set the filter with:
.filter(LookupKind.ACTIVITY, {postId}, DEFAULT, limit, "comment")

In the result "ownChildren" is always null. I would expect it to contain data if I had liked the comment (this is the behaviour in iOS).

I need that in order to identify the post I've liked.

How can I get my own reactions to to reactions?

Cheers

gz#12930

NoSuchMethod exception

On Android project, this copy-pasted code from examples is not working:

 try {
   Client client = Client.builder(<ApiKey>, <ApiSecret>).build();
   FlatFeed chris = client.flatFeed("user", "chris");
   chris.addActivity(Activity.builder()
                    .actor("chris")
                    .verb("add")
                    .object("picture:10")
                    .foreignID("picture:10")
                    .extraField("message", "Beautiful bird!")
                    .build());

} catch (MalformedURLException e) {
} catch (StreamException e) {}

chris.addActivity() throws this exception:

    java.lang.NoSuchMethodError: No static method encodeBase64URLSafeString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)
        at com.auth0.jwt.JWTCreator.sign(JWTCreator.java:330)
        at com.auth0.jwt.JWTCreator.access$100(JWTCreator.java:24)
        at com.auth0.jwt.JWTCreator$Builder.sign(JWTCreator.java:311)
        at io.getstream.core.utils.Auth.buildBackendToken(Auth.java:135)
        at io.getstream.core.utils.Auth.buildBackendToken(Auth.java:123)
        at io.getstream.core.utils.Auth.buildFeedToken(Auth.java:60)
        at io.getstream.client.Client.addActivity(Client.java:249)
        at io.getstream.client.Feed.addActivity(Feed.java:56)

Frontend token support

Does this library support making calls via the frontend token? I'm looking at embedding this in a mobile application and I don't see how this is done. Apologies if I'm missing something obvious!

FollowMany Bad signature exception

Hi

Calling followMany method like described in documentation gives me

Invoking url: 'https://eu-west-api.getstream.io/api/v1.0/follow_many/?activity_copy_limit=300 
AuthenticationFailedException{statusCode=403, code=0, exception=AuthenticationFailed, detail=Bad signature} 

and that's weird cause other API calls just work (follow single feed, add activity etc) and key/secret provided for StreamClient are correct.

Verb property instead of Type property

Hi,
In the example regarding MixedType, shouldn't it be
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "verb")
instead of current
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")

Thanks in advance.

Issue on converting EnrichedActivity to String

I need to convert EnrichedActivity to String as I use stream-java:3.2.4 in a Flutter application.

I get EnrichedActivity list like this:

  val list : List<EnrichedActivity> =   client.flatFeed("user").getEnrichedActivities(EnrichmentFlags()
             .withOwnReactions()
             .withRecentReactions()
             .withReactionCounts()).get()

Then I try to convert the list like this:

    val resultString = ObjectMapper()
                        .setSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS)
                        .writeValueAsString(list)

But some fields are erased by FasterXml-jackson (v2.9.6).

Isn't this the correct way to convert an EnrichedActivity list to String?


Note:
1- Original EnrichedActivity :

{EnrichedActivity@15673} "EnrichedActivity{id=5e02d656-27ef-11eb-88f9-128a130028af, actor=Data{id=RqO5ns7mrYfvain3ETQpdPgIQZz1, data={updated_at=2020-11-11T22:46:38.568116Z, name=RqO5ns7mrYfvain3ETQpdPgIQZz1, created_at=2020-11-11T22:46:38.568116Z}}, verb=post, object=Data{id=b0e249e9-8695-4161-bb24-d3980da4cdeb, data={}}, foreignID=, target=Data{id=, data={}}, time=Mon Nov 16 12:37:39 GMT+03:00 2020, origin=null, to=null, score=null, ownReactions={like=[Reaction{id=4186ea14-f3e5-4368-8a91-eafc12e3045b, appID=null, kind=like, userID=RqO5ns7mrYfvain3ETQpdPgIQZz1, activityID=5e02d656-27ef-11eb-88f9-128a130028af, parent=, ownChildren=null, latestChildren={}, childrenCounts={}, userData=Data{id=RqO5ns7mrYfvain3ETQpdPgIQZz1, data={updated_at=2020-11-11T22:46:38.568116Z, name=RqO5ns7mrYfvain3ETQpdPgIQZz1, created_at=2020-11-11T22:46:38.568116Z}}, activityData={}, extra={updated_at=2020-11-16T09:39:25.088760Z, created_at=2020-11-16T09:39:25.088760Z}}]}, latestReactions={like=[Reaction{id=4186ea14-f3e5-4368-8a91-eafc12"

2- The serialized form of the list:

[
{
"actor": {
"id": "RqO5ns7mrYfvain3ETQpdPgIQZz1",
"updated_at": "2020-11-11T22:46:38.568116Z",
"name": "RqO5ns7mrYfvain3ETQpdPgIQZz1",
"created_at": "2020-11-11T22:46:38.568116Z"
},
"id": "5e02d656-27ef-11eb-88f9-128a130028af",
"object": {
"id": "b0e249e9-8695-4161-bb24-d3980da4cdeb"
},
"target": {
"id": ""
},
"time": "2020-11-16T09:37:39.284",
"verb": "post",
"foreign_id": "",
"message": "test2",
"latest_reactions_extra": {
"like": {
"next": ""
}
}
}
]

NotAllowedException: You do not have permission to do this, you got this error because there are no policies allowing this request on this application.

NotAllowedException: You do not have permission to do this, you got this error because there are no policies allowing this request on this application.

    val client = CloudClient.builder(API_KEY, token, user).build()
    return client.flatFeed(team, "user_one").getActivities(Limit(25)).join()

team is my group name
user_one is the user name

Also, How can I get all feeds of all users in "team" group?

Thanks

Overall reaction add request is slow

        println("-------- Execution time2: " + (System.currentTimeMillis() - start).toString() + "ms")
->        val r = client.reactions().add(user, like).get()
        println("-------- Execution time3: " + (System.currentTimeMillis() - start).toString() + "ms")

this line is causing a 600ms delay

any way to make it faster?

Commons-codec Issue in Android Devices

The library is using JWT library that uses features of apache commons-codec that is only available in version 1.4 and higher, the problem is android runtime has a built in commons-codec that will always be used in runtime which is version 1.3. Therefore result to method "java.lang.NoSuchMethodError: No static method" error due to those features are not available yet in version 1.3 of commons codec.

gz#6908

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.