feedpollqueuehandler.php 957 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. if (!defined('GNUSOCIAL')) { exit(1); }
  3. /**
  4. * Poll a feed based on its urlhash, the full url is in the feedsub table
  5. *
  6. * @author Mikael Nordfeldth <mmn@hethane.se>
  7. */
  8. class FeedPollQueueHandler extends QueueHandler
  9. {
  10. public function transport()
  11. {
  12. return FeedPoll::QUEUE_CHECK;
  13. }
  14. public function handle($item) : bool
  15. {
  16. $feedsub = FeedSub::getKV('id', $item['id']);
  17. if (!$feedsub instanceof FeedSub) {
  18. // Removed from the feedsub table I guess
  19. return true;
  20. }
  21. if (!$feedsub->sub_state == 'nohub') {
  22. // We're not supposed to poll this (either it's WebSub or it's unsubscribed)
  23. return true;
  24. }
  25. try {
  26. FeedPoll::checkUpdates($feedsub);
  27. } catch (Exception $e) {
  28. common_log(LOG_ERR, "Failed to check feedsub id= ".$feedsub->id.' ("'.$e->getMessage().'")');
  29. }
  30. return true;
  31. }
  32. }