mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-25 11:43:40 +00:00
pumpio: Editing and deleting of own comments is now possible.
This commit is contained in:
parent
a2bbf957dd
commit
70bb288291
1 changed files with 34 additions and 17 deletions
|
@ -342,15 +342,21 @@ function pumpio_send(&$a,&$b) {
|
||||||
|
|
||||||
if($b['verb'] == ACTIVITY_LIKE) {
|
if($b['verb'] == ACTIVITY_LIKE) {
|
||||||
if ($b['deleted'])
|
if ($b['deleted'])
|
||||||
pumpio_like($a, $b["uid"], $b["thr-parent"], "unlike");
|
pumpio_action($a, $b["uid"], $b["thr-parent"], "unlike");
|
||||||
else
|
else
|
||||||
pumpio_like($a, $b["uid"], $b["thr-parent"], "like");
|
pumpio_action($a, $b["uid"], $b["thr-parent"], "like");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($b['verb'] == ACTIVITY_DISLIKE)
|
if($b['verb'] == ACTIVITY_DISLIKE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (($b['verb'] == ACTIVITY_POST) AND ($b['created'] !== $b['edited']) AND !$b['deleted'])
|
||||||
|
pumpio_action($a, $b["uid"], $b["uri"], "update", $b["body"]);
|
||||||
|
|
||||||
|
if (($b['verb'] == ACTIVITY_POST) AND $b['deleted'])
|
||||||
|
pumpio_action($a, $b["uid"], $b["uri"], "delete");
|
||||||
|
|
||||||
if($b['deleted'] || ($b['created'] !== $b['edited']))
|
if($b['deleted'] || ($b['created'] !== $b['edited']))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -475,7 +481,7 @@ function pumpio_send(&$a,&$b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_like($a, $uid, $uri, $action) {
|
function pumpio_action($a, $uid, $uri, $action, $content) {
|
||||||
$ckey = get_pconfig($uid, 'pumpio', 'consumer_key');
|
$ckey = get_pconfig($uid, 'pumpio', 'consumer_key');
|
||||||
$csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
|
$csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
|
||||||
$otoken = get_pconfig($uid, 'pumpio', 'oauth_token');
|
$otoken = get_pconfig($uid, 'pumpio', 'oauth_token');
|
||||||
|
@ -506,7 +512,9 @@ function pumpio_like($a, $uid, $uri, $action) {
|
||||||
$objectType = "image";
|
$objectType = "image";
|
||||||
|
|
||||||
$params["verb"] = $action;
|
$params["verb"] = $action;
|
||||||
$params["object"] = array('id' => $uri, "objectType" => $objectType);
|
$params["object"] = array('id' => $uri,
|
||||||
|
"objectType" => $objectType,
|
||||||
|
"content" => $content);
|
||||||
|
|
||||||
$client = new oauth_client_class;
|
$client = new oauth_client_class;
|
||||||
$client->oauth_version = '1.0a';
|
$client->oauth_version = '1.0a';
|
||||||
|
@ -523,9 +531,9 @@ function pumpio_like($a, $uid, $uri, $action) {
|
||||||
$success = $client->CallAPI($url, 'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
|
$success = $client->CallAPI($url, 'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
|
||||||
|
|
||||||
if($success)
|
if($success)
|
||||||
logger('pumpio_like '.$username.' '.$action.': success '.$uri);
|
logger('pumpio_action '.$username.' '.$action.': success '.$uri);
|
||||||
else {
|
else {
|
||||||
logger('pumpio_like '.$username.' '.$action.': general error: '.$uri.' '.print_r($user,true));
|
logger('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user,true));
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
|
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']);
|
||||||
if (count($r))
|
if (count($r))
|
||||||
|
@ -765,9 +773,9 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id) {
|
||||||
|
|
||||||
if(link_compare($post->actor->url, $own_id)) {
|
if(link_compare($post->actor->url, $own_id)) {
|
||||||
$contactid = $self[0]['id'];
|
$contactid = $self[0]['id'];
|
||||||
//$post->actor->displayName;
|
$post->actor->displayName = $self[0]['name'];
|
||||||
//$post->actor->url;
|
$post->actor->url = $self[0]['url'];
|
||||||
//$post->actor->image->url;
|
$post->actor->image->url = $self[0]['photo'];
|
||||||
} else {
|
} else {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
||||||
dbesc($post->actor->url),
|
dbesc($post->actor->url),
|
||||||
|
@ -1019,9 +1027,13 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id) {
|
||||||
} else {
|
} else {
|
||||||
$contact_id = 0;
|
$contact_id = 0;
|
||||||
|
|
||||||
if(link_compare($post->actor->url, $own_id))
|
if(link_compare($post->actor->url, $own_id)) {
|
||||||
$contact_id = $self[0]['id'];
|
$contact_id = $self[0]['id'];
|
||||||
else {
|
$post->actor->displayName = $self[0]['name'];
|
||||||
|
$post->actor->url = $self[0]['url'];
|
||||||
|
$post->actor->image->url = $self[0]['photo'];
|
||||||
|
} else {
|
||||||
|
// Take an existing contact, the contact of the note or - as a fallback - the id of the user
|
||||||
$r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
||||||
dbesc($post->actor->url),
|
dbesc($post->actor->url),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
|
@ -1029,10 +1041,17 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id) {
|
||||||
|
|
||||||
if(count($r))
|
if(count($r))
|
||||||
$contact_id = $r[0]['id'];
|
$contact_id = $r[0]['id'];
|
||||||
|
else {
|
||||||
|
$r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
|
||||||
|
dbesc($post->actor->url),
|
||||||
|
intval($uid)
|
||||||
|
);
|
||||||
|
|
||||||
if($contact_id == 0)
|
if(count($r))
|
||||||
$contact_id = $self[0]['id'];
|
$contact_id = $r[0]['id'];
|
||||||
//$contact_id = $orig_post['contact-id'];
|
else
|
||||||
|
$contact_id = $self[0]['id'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$reply->verb = "note";
|
$reply->verb = "note";
|
||||||
|
@ -1334,15 +1353,13 @@ function pumpio_queue_hook(&$a,&$b) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
To-Do:
|
To-Do:
|
||||||
- change own imported comments and likes to local user
|
|
||||||
- Editing and deleting of own comments
|
|
||||||
|
|
||||||
Could be hard to do:
|
Could be hard to do:
|
||||||
- Threads completion
|
- Threads completion
|
||||||
- edit own notes
|
- edit own notes
|
||||||
- delete own notes
|
- delete own notes
|
||||||
|
|
||||||
Problem:
|
Known issues:
|
||||||
- refresh after post
|
- refresh after post
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue