forked from friendica/friendica-addons
Support of "unique contacts" for the new API
This commit is contained in:
parent
70742b56c2
commit
5eb18422c4
|
@ -200,6 +200,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
|
|||
$postarray['wall'] = 0;
|
||||
|
||||
$postarray['verb'] = ACTIVITY_POST;
|
||||
$postarray['network'] = dbesc(NETWORK_FACEBOOK);
|
||||
|
||||
$postarray['uri'] = "fb::".$post->post_id;
|
||||
$postarray['thr-parent'] = $postarray['uri'];
|
||||
|
@ -414,6 +415,7 @@ function fbsync_createcomment($a, $uid, $self_id, $self, $user, $contacts, $appl
|
|||
$postarray['wall'] = 0;
|
||||
|
||||
$postarray['verb'] = ACTIVITY_POST;
|
||||
$postarray['network'] = dbesc(NETWORK_FACEBOOK);
|
||||
|
||||
$postarray['uri'] = "fb::".$comment->id;
|
||||
$postarray['thr-parent'] = $parent_uri;
|
||||
|
@ -548,13 +550,13 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
|
|||
$likedata = array();
|
||||
$likedata['parent'] = $orig_post['id'];
|
||||
$likedata['verb'] = ACTIVITY_LIKE;
|
||||
$likedate['network'] = dbesc(NETWORK_FACEBOOK);
|
||||
$likedata['gravity'] = 3;
|
||||
$likedata['uid'] = $uid;
|
||||
$likedata['wall'] = 0;
|
||||
$likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
|
||||
$likedata['parent-uri'] = $orig_post["uri"];
|
||||
$likedata['app'] = "Facebook";
|
||||
$likedata['verb'] = ACTIVITY_LIKE;
|
||||
|
||||
if ($like->user_id != $self_id) {
|
||||
$likedata['contact-id'] = $contact_id;
|
||||
|
@ -598,6 +600,24 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
|
|||
|
||||
function fbsync_fetch_contact($uid, $contact, $create_user) {
|
||||
|
||||
// Check if the unique contact is existing
|
||||
// To-Do: only update once a while
|
||||
$r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
|
||||
dbesc(normalise_link($contact->url)));
|
||||
|
||||
if (count($r) == 0)
|
||||
q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')",
|
||||
dbesc(normalise_link($contact->url)),
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->username),
|
||||
dbesc($contact->pic_square));
|
||||
else
|
||||
q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'",
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->username),
|
||||
dbesc($contact->pic_square),
|
||||
dbesc(normalise_link($contact->url)));
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc("facebook::".$contact->id));
|
||||
|
||||
|
@ -834,7 +854,7 @@ function fbsync_fetchfeed($a, $uid) {
|
|||
|
||||
require_once('include/items.php');
|
||||
|
||||
if ($last_updated == "")
|
||||
//if ($last_updated == "")
|
||||
$last_updated = 0;
|
||||
|
||||
logger("fbsync_fetchfeed: fetching content for user ".$self_id);
|
||||
|
|
|
@ -169,6 +169,7 @@ function twitter_settings_post ($a,$post) {
|
|||
del_pconfig(local_user(), 'twitter', 'intelligent_shortening');
|
||||
del_pconfig(local_user(), 'twitter', 'import');
|
||||
del_pconfig(local_user(), 'twitter', 'create_user');
|
||||
del_pconfig(local_user(), 'twitter', 'own_id');
|
||||
} else {
|
||||
if (isset($_POST['twitter-pin'])) {
|
||||
// if the user supplied us with a PIN from Twitter, let the magic of OAuth happen
|
||||
|
@ -632,8 +633,12 @@ function twitter_post_hook(&$a,&$b) {
|
|||
$orig_post = $r[0];
|
||||
}
|
||||
|
||||
// To-Do: Ab dem letzten / nehmen
|
||||
$b["body"] = "@".substr($orig_post["author-link"], 20)." ".$b["body"];
|
||||
$nickname = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
|
||||
$nickname = "@[url=".$orig_post["author-link"]."]".$nickname."[/url]";
|
||||
|
||||
logger("twitter_post_hook: comparing ".$nickname." with ".$b["body"], LOGGER_DEBUG);
|
||||
if (strpos($b["body"], $nickname) === false)
|
||||
$b["body"] = $nickname." ".$b["body"];
|
||||
|
||||
logger("twitter_post_hook: parent found ".print_r($orig_post, true), LOGGER_DATA);
|
||||
} else {
|
||||
|
@ -1119,6 +1124,24 @@ function twitter_queue_hook(&$a,&$b) {
|
|||
|
||||
function twitter_fetch_contact($uid, $contact, $create_user) {
|
||||
|
||||
// Check if the unique contact is existing
|
||||
// To-Do: only update once a while
|
||||
$r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
|
||||
dbesc(normalise_link("https://twitter.com/".$contact->screen_name)));
|
||||
|
||||
if (count($r) == 0)
|
||||
q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')",
|
||||
dbesc(normalise_link("https://twitter.com/".$contact->screen_name)),
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->screen_name),
|
||||
dbesc($contact->profile_image_url_https));
|
||||
else
|
||||
q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'",
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->screen_name),
|
||||
dbesc($contact->profile_image_url_https),
|
||||
dbesc(normalise_link("https://twitter.com/".$contact->screen_name)));
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc("twitter::".$contact->id_str));
|
||||
|
||||
|
@ -1191,6 +1214,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) {
|
|||
dbesc(datetime_convert()),
|
||||
intval($contact_id)
|
||||
);
|
||||
|
||||
} else {
|
||||
// update profile photos once every two weeks as we have no notification of when they change.
|
||||
|
||||
|
@ -1282,6 +1306,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
|
|||
$has_picture = false;
|
||||
|
||||
$postarray = array();
|
||||
$postarray['network'] = NETWORK_TWITTER;
|
||||
$postarray['gravity'] = 0;
|
||||
$postarray['uid'] = $uid;
|
||||
$postarray['wall'] = 0;
|
||||
|
@ -1425,6 +1450,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
|
|||
$postarray['body'] = $converted["body"];
|
||||
$postarray['tag'] = $converted["tags"];
|
||||
|
||||
twitter_fetch_contact($uid, $post->retweeted_status->user, false);
|
||||
|
||||
// Deactivated at the moment, since there are problems with answers to retweets
|
||||
if (false AND !intval(get_config('system','wall-to-wall_share'))) {
|
||||
|
@ -1757,7 +1783,8 @@ function twitter_siteinfo($url, $dontincludemedia) {
|
|||
|
||||
if (sizeof($data["images"]) > 0) {
|
||||
$imagedata = $data["images"][0];
|
||||
$text .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]' . "\n";
|
||||
//$text .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]' . "\n";
|
||||
$text .= '[img]'.$imagedata["src"].'[/img]'."\n";
|
||||
}
|
||||
|
||||
if (is_string($data["text"]))
|
||||
|
@ -1914,6 +1941,9 @@ function twitter_fetch_own_contact($a, $uid) {
|
|||
intval($uid), dbesc("twitter::".$own_id));
|
||||
if(count($r))
|
||||
$contact_id = $r[0]["id"];
|
||||
else
|
||||
del_pconfig($uid, 'twitter', 'own_id');
|
||||
|
||||
}
|
||||
|
||||
return($contact_id);
|
||||
|
|
Loading…
Reference in a new issue