123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
- class DistribQueueHandler
- {
-
- public function transport()
- {
- return 'distrib';
- }
-
- public function handle(Notice $notice) : bool
- {
-
- $ptAtts = $notice->getAttentionsFromProfileTags();
- foreach (array_keys($ptAtts) as $profile_id) {
- $profile = Profile::getKV('id', $profile_id);
- if ($profile instanceof Profile) {
- try {
- common_debug('Adding Attention for '.$notice->getID().' profile '.$profile->getID());
- Attention::saveNew($notice, $profile);
- } catch (Exception $e) {
- $this->logit($notice, $e);
- }
- }
- }
- try {
- $notice->sendReplyNotifications();
- } catch (Exception $e) {
- $this->logit($notice, $e);
- }
- try {
- Event::handle('EndNoticeDistribute', array($notice));
- } catch (Exception $e) {
- $this->logit($notice, $e);
- }
- try {
- Event::handle('EndNoticeSave', array($notice));
- } catch (Exception $e) {
- $this->logit($notice, $e);
- }
- try {
-
- common_enqueue_notice($notice);
- } catch (Exception $e) {
- $this->logit($notice, $e);
- }
- return true;
- }
- protected function logit($notice, $e)
- {
- common_log(LOG_ERR, "Distrib queue exception saving notice $notice->id: " .
- $e->getMessage() . ' ' .
- str_replace("\n", " ", $e->getTraceAsString()));
-
-
- }
- }
|