123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- define('RSSCLOUDPLUGIN_VERSION', '0.1.0');
- class RSSCloudPlugin extends Plugin
- {
-
- function __construct()
- {
- parent::__construct();
- }
-
- function onInitializePlugin()
- {
- $this->domain = common_config('rsscloud', 'domain');
- $this->port = common_config('rsscloud', 'port');
- $this->path = common_config('rsscloud', 'path');
- $this->funct = common_config('rsscloud', 'function');
- $this->protocol = common_config('rsscloud', 'protocol');
-
- $local_server = parse_url(common_path('main/rsscloud/request_notify'));
- if (empty($this->domain)) {
- $this->domain = $local_server['host'];
- }
- if (empty($this->port)) {
- $this->port = '80';
- }
- if (empty($this->path)) {
- $this->path = $local_server['path'];
- }
- if (empty($this->funct)) {
- $this->funct = '';
- }
- if (empty($this->protocol)) {
- $this->protocol = 'http-post';
- }
- }
-
- function onRouterInitialized($m)
- {
- $m->connect('/main/rsscloud/request_notify',
- ['action' => 'RSSCloudRequestNotify']);
-
-
-
-
- return true;
- }
-
- function onStartApiRss($action)
- {
- if (get_class($action) == 'ApiTimelineUserAction') {
- $attrs = array('domain' => $this->domain,
- 'port' => $this->port,
- 'path' => $this->path,
- 'registerProcedure' => $this->funct,
- 'protocol' => $this->protocol);
-
- $action->xw->startElement('cloud');
- foreach ($attrs as $name => $value) {
- $action->xw->writeAttribute($name, $value);
- }
- $action->xw->endElement();
- }
- }
-
- function onStartEnqueueNotice($notice, &$transports)
- {
- if ($notice->isLocal()) {
- array_push($transports, 'rsscloud');
- }
- return true;
- }
-
- function onCheckSchema()
- {
- $schema = Schema::get();
- $schema->ensureTable('rsscloud_subscription',
- array(
- 'fields' => array(
- 'subscribed' => array('type' => 'int', 'not null' => true),
- 'url' => array('type' => 'varchar', 'length' => '191', 'not null' => true),
- 'failures' => array('type' => 'int', 'not null' => true, 'default' => 0),
- 'created' => array('type' => 'datetime', 'not null' => true),
- 'modified' => array('type' => 'timestamp', 'not null' => true),
- ),
- 'primary key' => array('subscribed', 'url'),
- ));
- return true;
- }
-
- function onEndInitializeQueueManager($manager)
- {
- $manager->connect('rsscloud', 'RSSCloudQueueHandler');
- return true;
- }
- public function onPluginVersion(array &$versions): bool
- {
- $versions[] = array('name' => 'RSSCloud',
- 'version' => RSSCLOUDPLUGIN_VERSION,
- 'author' => 'Zach Copley',
- 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/RSSCloud',
- 'rawdescription' =>
-
- _m('The RSSCloud plugin enables your StatusNet instance to publish ' .
- 'real-time updates for profile RSS feeds using the ' .
- '<a href="http://rsscloud.org/">RSSCloud protocol</a>.'));
- return true;
- }
- }
|