// More options
let query = FeedQuery(
group: "user",
id: "jack",
data: .init(
visibility: "public"
)
)
let feed = client.feed(for: query)
try await feed.getOrCreate()Feed and Activity Visibility
Feed Visibility Levels
Feed groups have a default visibility (if it's not set when creating the group, visible will be set). You can also override the group's default when creating a feed. A feed's visibility level can't be changed after creation.
import io.getstream.services.FeedsImpl;
import io.getstream.services.Feed;
import io.getstream.models.*;
FeedsImpl feedsClient = new FeedsImpl(new StreamHTTPClient("<API key>", "<API secret>"));
// Create a feed with custom visibility
Feed feed = new Feed("user", "jack", feedsClient);
GetOrCreateFeedRequest feedRequest = GetOrCreateFeedRequest.builder()
.userID("jack")
.data(FeedInput.builder()
.visibility("public")
.build())
.build();
feed.getOrCreate(feedRequest);
// Create a feed group with default visibility
CreateFeedGroupRequest groupRequest = CreateFeedGroupRequest.builder()
.id("myid")
.defaultVisibility("public")
.activityProcessors(List.of(
ActivityProcessorConfig.builder().type("default").build()
))
.build();
CreateFeedGroupResponse groupResponse = feedsClient.createFeedGroup(groupRequest).execute().getData();Supported visibility levels:
| Level | Viewing feed (activities + metadata) | Following | Posting |
|---|---|---|---|
visible | Anyone can view | Anyone can follow | Only the owner or member/follower with the post permission can post |
public | Anyone can view | Anyone can follow | Anyone can post |
followers | Only approved followers can view | Anyone can send a follow request, follow requests have to be approved | Only the owner or member/follower with the post permission can post |
members | Only members can view | Only members can follow | Only the owner or member/follower with the post permission can post |
private | Only the owner can view | Only the owner can follow | Only the owner can post |
Activity Visibility Levels
public: marks the activity as public - everyone who can view feed content, can see itprivate: marks the activity as private - only feed owner can see ittag:mytag: marks the activity as only visible to followers/members with the permission to see this tag
This visibility system is very flexible and allows you to build:
- Apps like Patreon where only certain levels of users can see your content
- Apps like Strava where it's possible to share your activity with nobody, everyone or your followers
let privateActivity = try await feed.addActivity(
request: .init(
text: "Premium content",
type: "post",
visibility: .tag,
visibilityTag: "premium"
)
)
// Premium users can see full activity, others a previewFor all the details on tag visibility read the Membership levels guide.