I'd like to propose adding a hook_twitter_fetch_user_timeline() that executes just prior to retrieving recent tweets from Twitter and adding them to the Drupal database. Among other things, this could support a custom-coded module that satisfies a feature request which has come up repeatedly to be able to remove deleted tweets from the Drupal site if they have been deleted from Drupal.com:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sheldon Rampton’s picture

Status: Active » Needs review
FileSize
1.31 KB

Here's a patch that adds the hook.

Sheldon Rampton’s picture

I've created a sandbox "Twitter delete" module that illustrates how this hook can be used to support deletion of a user's already-archived tweets before fetching the user timeline from Twitter:

http://drupal.org/sandbox/sheldon/1943460

I think my sandbox module would satisfy most of the real-world use cases where people want their Drupal site to stop displaying tweets that have been removed from Twitter. It accomplishes this by simply deleting a user's entire history of tweets before fetching the timeline. This might be a problem for websites that are using the Twitter module to collect a full history of a user's tweets and archive them on Drupal.org, but on the website where I'm using the Twitter module, this isn't an issue. We're simply using the Twitter module as a mechanism for caching a list of recent tweets so my website doesn't have to keep hitting Twitter's API (and running up against the limits of its rate limiter) every time it displays a Twitter block on a page. For reading older tweets, we just give the user a link to Twitter.

My website is the NYSenate.gov (the official website of the New York State Senate), and we need the ability to remove deleted tweets because Senators want to feel confident that if they remove a tweet from Twitter, it will also be promptly removed from NYSenate.gov. Without that confidence, they will not not feel comfortable adding their Twitter blocks to our website. There have been instances where public officials have accidentally posted erroneous information on Twitter, and they want to know that if they make that sort of mistake, they can fix it promptly themselves.

In one of the messages explaining the reasoning for making a "won't fix" decision to past requests for a feature that would support removing deleted tweets, user juampy suggested that it would be "Better to delete it manually or wait until it is automatically deleted after a certain amount of time configured at the module settings page." This suggestion is not a solution for the senators who use NYSenate.gov. We have 64 New York State Senators whose offices all post content to our website, and it would not be practical to create a system through which the staffs working in 64 different offices all have the ability to manually delete individual tweets. It is also not realistic to expect that a senator who wants a tweet removed manually will be willing to wait an hour or several hours, or possibly days, before a request to manually remove a tweet can be relayed to our technical support team and acted upon.

I'm posting this explanation so the Twitter module's maintainers can see how my "Twitter delete" module fills a real need and why hook_twitter_fetch_user_timeline() is therefore useful. It also provides a mechanism by which someone could create a more robust Twitter delete module that zaps recent deleted tweets without deleting older history.

Sheldon Rampton’s picture

Issue summary: View changes

fix typo

xurizaemon’s picture

Version: 6.x-5.x-dev » 7.x-5.x-dev
Issue summary: View changes
Status: Needs review » Needs work

Happy to consider addition of this if re-rolled for 7.x-5.x.

DamienMcKenna’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: hook_twitter_fetch_user_timeline-1943440-1.patch, failed testing.

DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
1.55 KB

Rerolled.

Status: Needs review » Needs work

The last submitted patch, 6: twitter-n1943440-6.patch, failed testing.

DamienMcKenna’s picture

Title: Add hook_twitter_fetch_user_timeline() » Add hooks around timeline loading
Version: 7.x-5.x-dev » 7.x-6.x-dev
FileSize
2.83 KB

This extends the idea so that there's now hook_twitter_prefetch_timeline(), hook_twitter_statuses_alter() and hook_twitter_insert_statuses().

DamienMcKenna’s picture

Status: Needs work » Needs review
DamienMcKenna’s picture

Version: 7.x-6.x-dev » 7.x-5.x-dev
FileSize
2.87 KB

Ported to 7.x-5.x.

DamienMcKenna’s picture

Version: 7.x-5.x-dev » 6.x-5.x-dev
FileSize
2.87 KB

Ported to 6.x-5.x.

The last submitted patch, 9: twitter-n1943440-9-7.x-6.x.patch, failed testing.

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

  • DamienMcKenna committed 46eb7fb on 6.x-5.x
    Issue #1943440 by DamienMcKenna, Sheldon Rampton: Added new hooks around...

  • DamienMcKenna committed 63b110b on 7.x-5.x
    Issue #1943440 by DamienMcKenna, Sheldon Rampton: Added new hooks around...

  • DamienMcKenna committed f5579a3 on 7.x-6.x
    Issue #1943440 by DamienMcKenna, Sheldon Rampton: Added new hooks around...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.