forked from friendica/friendica-addons
App.net/Pump.io/GNU Social/Twitter: Support for new notifications
This commit is contained in:
parent
050f885f48
commit
91757d72d8
|
@ -15,6 +15,8 @@
|
|||
- https://alpha.app.net/opendev/post/34396399 - location data
|
||||
*/
|
||||
|
||||
require_once('include/enotify.php');
|
||||
|
||||
define('APPNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
||||
|
||||
function appnet_install() {
|
||||
|
@ -25,6 +27,7 @@ function appnet_install() {
|
|||
register_hook('connector_settings', 'addon/appnet/appnet.php', 'appnet_settings');
|
||||
register_hook('connector_settings_post','addon/appnet/appnet.php', 'appnet_settings_post');
|
||||
register_hook('prepare_body', 'addon/appnet/appnet.php', 'appnet_prepare_body');
|
||||
register_hook('check_item_notification','addon/appnet/appnet.php', 'appnet_check_item_notification');
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,6 +39,7 @@ function appnet_uninstall() {
|
|||
unregister_hook('connector_settings', 'addon/appnet/appnet.php', 'appnet_settings');
|
||||
unregister_hook('connector_settings_post', 'addon/appnet/appnet.php', 'appnet_settings_post');
|
||||
unregister_hook('prepare_body', 'addon/appnet/appnet.php', 'appnet_prepare_body');
|
||||
unregister_hook('check_item_notification','addon/appnet/appnet.php', 'appnet_check_item_notification');
|
||||
}
|
||||
|
||||
function appnet_module() {}
|
||||
|
@ -64,6 +68,18 @@ function appnet_content(&$a) {
|
|||
return $o;
|
||||
}
|
||||
|
||||
function appnet_check_item_notification($a, &$notification_data) {
|
||||
$own_id = get_pconfig($notification_data["uid"], 'appnet', 'ownid');
|
||||
|
||||
$own_user = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($notification_data["uid"]),
|
||||
dbesc("adn::".$own_id)
|
||||
);
|
||||
|
||||
if ($own_user)
|
||||
$notification_data["profiles"][] = $own_user[0]["url"];
|
||||
}
|
||||
|
||||
function appnet_plugin_admin(&$a, &$o){
|
||||
$t = get_markup_template( "admin.tpl", "addon/appnet/" );
|
||||
|
||||
|
@ -707,7 +723,7 @@ function appnet_fetchstream($a, $uid) {
|
|||
|
||||
$lastid = $post["id"];
|
||||
|
||||
if (($item != 0) AND ($postarray['contact-id'] != $me["id"])) {
|
||||
if (($item != 0) AND ($postarray['contact-id'] != $me["id"]) AND !function_exists("check_item_notification")) {
|
||||
$r = q("SELECT `thread`.`iid` AS `parent` FROM `thread`
|
||||
INNER JOIN `item` ON `thread`.`iid` = `item`.`parent` AND `thread`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`id` = %d AND `thread`.`mention` LIMIT 1", dbesc($item));
|
||||
|
@ -769,6 +785,10 @@ function appnet_fetchstream($a, $uid) {
|
|||
|
||||
$parent_id = 0;
|
||||
logger('appnet_fetchstream: User '.$uid.' posted mention item '.$item);
|
||||
|
||||
if ($item AND function_exists("check_item_notification"))
|
||||
check_item_notification($item, $uid, NOTIFY_TAGSELF);
|
||||
|
||||
} else {
|
||||
$item = 0;
|
||||
$parent_id = 0;
|
||||
|
@ -790,7 +810,7 @@ function appnet_fetchstream($a, $uid) {
|
|||
$lastid = $post["id"];
|
||||
|
||||
//if (($item != 0) AND ($postarray['contact-id'] != $me["id"])) {
|
||||
if ($item != 0) {
|
||||
if (($item != 0) AND !function_exists("check_item_notification")) {
|
||||
require_once('include/enotify.php');
|
||||
notification(array(
|
||||
'type' => NOTIFY_TAGSELF,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
require('addon/pumpio/oauth/http.php');
|
||||
require('addon/pumpio/oauth/oauth_client.php');
|
||||
require_once('include/enotify.php');
|
||||
|
||||
define('PUMPIO_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
||||
|
||||
|
@ -18,6 +19,7 @@ function pumpio_install() {
|
|||
register_hook('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
||||
register_hook('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
||||
register_hook('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
||||
register_hook('check_item_notification','addon/pumpio/pumpio.php', 'pumpio_check_item_notification');
|
||||
}
|
||||
|
||||
function pumpio_uninstall() {
|
||||
|
@ -28,6 +30,7 @@ function pumpio_uninstall() {
|
|||
unregister_hook('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
||||
unregister_hook('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
||||
unregister_hook('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
||||
unregister_hook('check_item_notification','addon/pumpio/pumpio.php', 'pumpio_check_item_notification');
|
||||
}
|
||||
|
||||
function pumpio_module() {}
|
||||
|
@ -57,6 +60,14 @@ function pumpio_content(&$a) {
|
|||
return $o;
|
||||
}
|
||||
|
||||
function pumpio_check_item_notification($a, &$notification_data) {
|
||||
$hostname = get_pconfig($notification_data["uid"], 'pumpio','host');
|
||||
$username = get_pconfig($notification_data["uid"], "pumpio", "user");
|
||||
|
||||
$notification_data["profiles"][] = "https://".$hostname."/".$username;
|
||||
}
|
||||
|
||||
|
||||
function pumpio_registerclient(&$a, $host) {
|
||||
|
||||
$url = "https://".$host."/api/client/register";
|
||||
|
@ -857,17 +868,19 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru
|
|||
|
||||
// Searching for the liked post
|
||||
// Two queries for speed issues
|
||||
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `network` = '%s' LIMIT 1",
|
||||
dbesc($post->object->id),
|
||||
intval($uid)
|
||||
intval($uid),
|
||||
dbesc(NETWORK_PUMPIO)
|
||||
);
|
||||
|
||||
if (count($r))
|
||||
$orig_post = $r[0];
|
||||
else {
|
||||
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d AND `network` = '%s' LIMIT 1",
|
||||
dbesc($post->object->id),
|
||||
intval($uid)
|
||||
intval($uid),
|
||||
dbesc(NETWORK_PUMPIO)
|
||||
);
|
||||
|
||||
if (!count($r))
|
||||
|
@ -1306,42 +1319,44 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
|
|||
if (link_compare($own_id, $postarray['author-link']))
|
||||
return $top_item;
|
||||
|
||||
$myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0",
|
||||
dbesc($postarray['parent-uri']),
|
||||
intval($uid)
|
||||
);
|
||||
if (!function_exists("check_item_notification")) {
|
||||
$myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0",
|
||||
dbesc($postarray['parent-uri']),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if(count($myconv)) {
|
||||
if(count($myconv)) {
|
||||
|
||||
foreach($myconv as $conv) {
|
||||
// now if we find a match, it means we're in this conversation
|
||||
foreach($myconv as $conv) {
|
||||
// now if we find a match, it means we're in this conversation
|
||||
|
||||
if(!link_compare($conv['author-link'],$importer_url) AND !link_compare($conv['author-link'],$own_id))
|
||||
continue;
|
||||
if(!link_compare($conv['author-link'],$importer_url) AND !link_compare($conv['author-link'],$own_id))
|
||||
continue;
|
||||
|
||||
require_once('include/enotify.php');
|
||||
require_once('include/enotify.php');
|
||||
|
||||
$conv_parent = $conv['parent'];
|
||||
$conv_parent = $conv['parent'];
|
||||
|
||||
notification(array(
|
||||
'type' => NOTIFY_COMMENT,
|
||||
'notify_flags' => $user[0]['notify-flags'],
|
||||
'language' => $user[0]['language'],
|
||||
'to_name' => $user[0]['username'],
|
||||
'to_email' => $user[0]['email'],
|
||||
'uid' => $user[0]['uid'],
|
||||
'item' => $postarray,
|
||||
'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($top_item)),
|
||||
'source_name' => $postarray['author-name'],
|
||||
'source_link' => $postarray['author-link'],
|
||||
'source_photo' => $postarray['author-avatar'],
|
||||
'verb' => ACTIVITY_POST,
|
||||
'otype' => 'item',
|
||||
'parent' => $conv_parent,
|
||||
));
|
||||
notification(array(
|
||||
'type' => NOTIFY_COMMENT,
|
||||
'notify_flags' => $user[0]['notify-flags'],
|
||||
'language' => $user[0]['language'],
|
||||
'to_name' => $user[0]['username'],
|
||||
'to_email' => $user[0]['email'],
|
||||
'uid' => $user[0]['uid'],
|
||||
'item' => $postarray,
|
||||
'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($top_item)),
|
||||
'source_name' => $postarray['author-name'],
|
||||
'source_link' => $postarray['author-link'],
|
||||
'source_photo' => $postarray['author-avatar'],
|
||||
'verb' => ACTIVITY_POST,
|
||||
'otype' => 'item',
|
||||
'parent' => $conv_parent,
|
||||
));
|
||||
|
||||
// only send one notification
|
||||
break;
|
||||
// only send one notification
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
define('STATUSNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
||||
|
||||
require_once('library/twitteroauth.php');
|
||||
require_once('include/enotify.php');
|
||||
|
||||
class StatusNetOAuth extends TwitterOAuth {
|
||||
function get_maxlength() {
|
||||
|
@ -119,6 +120,7 @@ function statusnet_install() {
|
|||
register_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
|
||||
register_hook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
|
||||
register_hook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
|
||||
register_hook('check_item_notification','addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
|
||||
logger("installed GNU Social");
|
||||
}
|
||||
|
||||
|
@ -131,6 +133,7 @@ function statusnet_uninstall() {
|
|||
unregister_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
|
||||
unregister_hook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
|
||||
unregister_hook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
|
||||
unregister_hook('check_item_notification','addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
|
||||
|
||||
// old setting - remove only
|
||||
unregister_hook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
|
||||
|
@ -139,6 +142,10 @@ function statusnet_uninstall() {
|
|||
|
||||
}
|
||||
|
||||
function statusnet_check_item_notification($a, &$notification_data) {
|
||||
$notification_data["profiles"][] = get_pconfig($notification_data["uid"], 'statusnet', 'own_url');
|
||||
}
|
||||
|
||||
function statusnet_jot_nets(&$a,&$b) {
|
||||
if(! local_user())
|
||||
return;
|
||||
|
@ -1443,7 +1450,7 @@ function statusnet_fetchhometimeline($a, $uid, $mode = 1) {
|
|||
|
||||
logger('statusnet_fetchhometimeline: User '.$self["nick"].' posted home timeline item '.$item);
|
||||
|
||||
if ($item != 0)
|
||||
if ($item AND !function_exists("check_item_notification"))
|
||||
statusnet_checknotification($a, $uid, $nick, $item, $postarray);
|
||||
}
|
||||
|
||||
|
@ -1493,6 +1500,9 @@ function statusnet_fetchhometimeline($a, $uid, $mode = 1) {
|
|||
$postarray["id"] = $item;
|
||||
|
||||
logger('statusnet_fetchhometimeline: User '.$self["nick"].' posted mention timeline item '.$item);
|
||||
|
||||
if ($item AND function_exists("check_item_notification"))
|
||||
check_item_notification($item, $uid, NOTIFY_TAGSELF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1505,7 +1515,7 @@ function statusnet_fetchhometimeline($a, $uid, $mode = 1) {
|
|||
$parent_id = $r[0]['parent'];
|
||||
}
|
||||
|
||||
if ($item != 0) {
|
||||
if (($item != 0) AND !function_exists("check_item_notification")) {
|
||||
require_once('include/enotify.php');
|
||||
notification(array(
|
||||
'type' => NOTIFY_TAGSELF,
|
||||
|
@ -1536,6 +1546,7 @@ function statusnet_complete_conversation($a, $uid, $self, $create_user, $nick, $
|
|||
$api = get_pconfig($uid, 'statusnet', 'baseapi');
|
||||
$otoken = get_pconfig($uid, 'statusnet', 'oauthtoken');
|
||||
$osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
|
||||
$own_url = get_pconfig($uid, 'statusnet', 'own_url');
|
||||
|
||||
require_once('library/twitteroauth.php');
|
||||
|
||||
|
@ -1559,7 +1570,7 @@ function statusnet_complete_conversation($a, $uid, $self, $create_user, $nick, $
|
|||
|
||||
logger('statusnet_complete_conversation: User '.$self["nick"].' posted home timeline item '.$item);
|
||||
|
||||
if ($item != 0)
|
||||
if ($item AND !function_exists("check_item_notification"))
|
||||
statusnet_checknotification($a, $uid, $nick, $item, $postarray);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@
|
|||
* Requirements: PHP5, curl [Slinky library]
|
||||
*/
|
||||
|
||||
require_once('include/enotify.php');
|
||||
|
||||
define('TWITTER_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
||||
|
||||
function twitter_install() {
|
||||
|
@ -74,6 +76,7 @@ function twitter_install() {
|
|||
register_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
|
||||
register_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
|
||||
register_hook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
|
||||
register_hook('check_item_notification','addon/twitter/twitter.php', 'twitter_check_item_notification');
|
||||
logger("installed twitter");
|
||||
}
|
||||
|
||||
|
@ -89,6 +92,7 @@ function twitter_uninstall() {
|
|||
unregister_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
|
||||
unregister_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
|
||||
unregister_hook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
|
||||
unregister_hook('check_item_notification','addon/twitter/twitter.php', 'twitter_check_item_notification');
|
||||
|
||||
// old setting - remove only
|
||||
unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
|
||||
|
@ -97,6 +101,18 @@ function twitter_uninstall() {
|
|||
|
||||
}
|
||||
|
||||
function twitter_check_item_notification($a, &$notification_data) {
|
||||
$own_id = get_pconfig($notification_data["uid"], 'twitter', 'own_id');
|
||||
|
||||
$own_user = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($notification_data["uid"]),
|
||||
dbesc("twitter::".$own_id)
|
||||
);
|
||||
|
||||
if ($own_user)
|
||||
$notification_data["profiles"][] = $own_user[0]["url"];
|
||||
}
|
||||
|
||||
function twitter_follow($a, &$contact) {
|
||||
|
||||
logger("twitter_follow: Check if contact is twitter contact. ".$contact["url"], LOGGER_DEBUG);
|
||||
|
@ -1580,7 +1596,7 @@ function twitter_fetchparentposts($a, $uid, $post, $connection, $self, $own_id)
|
|||
|
||||
if (count($r))
|
||||
break;
|
||||
|
||||
|
||||
$posts[] = $post;
|
||||
}
|
||||
|
||||
|
@ -1600,7 +1616,7 @@ function twitter_fetchparentposts($a, $uid, $post, $connection, $self, $own_id)
|
|||
|
||||
logger('twitter_fetchparentpost: User '.$self["nick"].' posted parent timeline item '.$item);
|
||||
|
||||
if ($item != 0)
|
||||
if ($item AND !function_exists("check_item_notification"))
|
||||
twitter_checknotification($a, $uid, $own_id, $item, $postarray);
|
||||
}
|
||||
}
|
||||
|
@ -1710,7 +1726,7 @@ function twitter_fetchhometimeline($a, $uid) {
|
|||
|
||||
logger('twitter_fetchhometimeline: User '.$self["nick"].' posted home timeline item '.$item);
|
||||
|
||||
if ($item != 0)
|
||||
if ($item AND !function_exists("check_item_notification"))
|
||||
twitter_checknotification($a, $uid, $own_id, $item, $postarray);
|
||||
|
||||
}
|
||||
|
@ -1755,6 +1771,9 @@ function twitter_fetchhometimeline($a, $uid) {
|
|||
$item = item_store($postarray);
|
||||
$postarray["id"] = $item;
|
||||
|
||||
if ($item AND function_exists("check_item_notification"))
|
||||
check_item_notification($item, $uid, NOTIFY_TAGSELF);
|
||||
|
||||
if (!isset($postarray["parent"]) OR ($postarray["parent"] == 0))
|
||||
$postarray["parent"] = $item;
|
||||
|
||||
|
@ -1772,7 +1791,7 @@ function twitter_fetchhometimeline($a, $uid) {
|
|||
} else
|
||||
$parent_id = $postarray['parent'];
|
||||
|
||||
if ($item != 0) {
|
||||
if (($item != 0) AND !function_exists("check_item_notification")) {
|
||||
require_once('include/enotify.php');
|
||||
notification(array(
|
||||
'type' => NOTIFY_TAGSELF,
|
||||
|
|
Loading…
Reference in a new issue