Skip to content
This repository

Favorite events #95

Open
a2m opened this Issue · 7 comments

4 participants

a2m Steve Agalloco Marc Cooper Erik Michaels-Ober
a2m
a2m commented

Favorite events have no corresponding objects in the Twitter gem, and are passed as simple hashes to the anything_proc.

This is quite inconvenient, as favorite events have quite basic attributes such as :created_at (as a string instead of a parsed time) and not so basic attributes such as :target, :source, and :target_object which do correspond to existing classes (Twitter::User and Twitter::Status).

As far as I can tell, these events are never used by the REST api, so the Twitter gem may never implement a class to represent a favorite event properly.

For reference, here is an example hash returned for a favorite event: https://gist.github.com/3269329

Steve Agalloco
Owner

I have an idea for how to support this, might take me a few days to put it in place. Thanks.

Steve Agalloco
Owner

I just added support for this in bdf7179, it will be released in 2.2.0 which I will push in the next several days. You can now do this to handle userstream events:

@client.on_event(:favorite) do |event|
  # do something
end

@client.userstream

You can create individual callbacks for each event cc/ @auxbuss

Steve Agalloco
Owner

This brings up an interesting design proposition. Rather than having individual callback methods for each type of message from Twitter (i.e., on_scrub_geooron_limit`), we could migrate towards a similar structure as above:

@client.on(:limit) do |limit|
  # do something
end

@client.on(:scrub_geo) do |scrub_geo|
  # do something
end

@client.on(:unauthorized) do
  # do something
end

This might help reduce some of the redundancy that's starting to occur in Client. Any thoughts? cc/ @sferik @mbleigh

Marc Cooper

Definitely gets the thumbs up from me.

Erik Michaels-Ober
Owner

Favorite events have no corresponding objects in the Twitter gem, and are passed as simple hashes to the anything_proc

Is there any particular reason not to use Twitter::Action::Favorite?

a2m
a2m commented

@sferik the Twitter::Action::Favorite class appears to only hold a list of target tweets to favorite on the rest api, and no information about the actor, or action itself (e.g. time of action, who favorited), and therefore cannot fully represent the streaming api's favorite events.

Erik Michaels-Ober
Owner

It inherits from Twitter::Action::Tweet, which defines a sources method. It should have everything you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.