Skip to content

Instantly share code, notes, and snippets.

@ruggi
Created January 17, 2018 14:02
Show Gist options
  • Save ruggi/5c95c7f1dd87f050c6c97078af636c0f to your computer and use it in GitHub Desktop.
Save ruggi/5c95c7f1dd87f050c6c97078af636c0f to your computer and use it in GitHub Desktop.
bob := client.FlatFeed("user", "bob")
alice := client.NotificationFeed("notification", "alice")
activity := stream.Activity{
Actor: "user:bob",
Verb: "tweet",
Object: "hanging out with @alice and @carol",
ForeignID: "fid:123",
Time: stream.Time{time.Now()},
To: []string{
alice.ID(),
"notification:carol",
},
}
// alice's and carol's notification feeds will receive the activity.
_, err := bob.AddActivity(activity)
if err != nil {
// ...
}
// Update the "to" targets of the activity so that it's sent to david but not to
// carol anymore
err = bob.UpdateToTargets(activity,
stream.WithToTargetsAdd("notification:david"),
stream.WithToTargetsRemove("notification:carol"),
)
if err != nil {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment