New implementation is now live.
This commit is contained in:
parent
07818a6553
commit
2841aa0281
|
@ -68,7 +68,7 @@ function delivery_run(&$argv, &$argc){
|
||||||
dbesc($contact_id)
|
dbesc($contact_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if((! $item_id) || (! $contact_id))
|
if (!$item_id || !$contact_id)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$expire = false;
|
$expire = false;
|
||||||
|
@ -230,7 +230,7 @@ function delivery_run(&$argv, &$argc){
|
||||||
|
|
||||||
$relay_to_owner = false;
|
$relay_to_owner = false;
|
||||||
|
|
||||||
if((! $top_level) && ($parent['wall'] == 0) && (! $expire) && (stristr($target_item['uri'],$localhost))) {
|
if (!$top_level && ($parent['wall'] == 0) && !$expire && stristr($target_item['uri'],$localhost)) {
|
||||||
$relay_to_owner = true;
|
$relay_to_owner = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ function delivery_run(&$argv, &$argc){
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// private emails may be in included in public conversations. Filter them.
|
// private emails may be in included in public conversations. Filter them.
|
||||||
if(($public_message) && $item['private'])
|
if ($public_message && $item['private'])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$item_contact = get_item_contact($item,$icontacts);
|
$item_contact = get_item_contact($item,$icontacts);
|
||||||
|
@ -349,8 +349,8 @@ function delivery_run(&$argv, &$argc){
|
||||||
|
|
||||||
if ($x && count($x)) {
|
if ($x && count($x)) {
|
||||||
$write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false);
|
$write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false);
|
||||||
if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) {
|
if ((($owner['page-flags'] == PAGE_COMMUNITY) || $write_flag) && !$x[0]['writable']) {
|
||||||
q("update contact set writable = 1 where id = %d",
|
q("UPDATE `contact` SET `writable` = 1 WHERE `id` = %d",
|
||||||
intval($x[0]['id'])
|
intval($x[0]['id'])
|
||||||
);
|
);
|
||||||
$x[0]['writable'] = 1;
|
$x[0]['writable'] = 1;
|
||||||
|
@ -439,7 +439,7 @@ function delivery_run(&$argv, &$argc){
|
||||||
|
|
||||||
// only expose our real email address to true friends
|
// only expose our real email address to true friends
|
||||||
|
|
||||||
if(($contact['rel'] == CONTACT_IS_FRIEND) && (! $contact['blocked'])) {
|
if (($contact['rel'] == CONTACT_IS_FRIEND) && !$contact['blocked']) {
|
||||||
if ($reply_to) {
|
if ($reply_to) {
|
||||||
$headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$reply_to.'>'."\n";
|
$headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$reply_to.'>'."\n";
|
||||||
$headers .= 'Sender: '.$local_user[0]['email']."\n";
|
$headers .= 'Sender: '.$local_user[0]['email']."\n";
|
||||||
|
@ -500,14 +500,15 @@ function delivery_run(&$argv, &$argc){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ($mail) {
|
if ($mail) {
|
||||||
diaspora_send_mail($item,$owner,$contact);
|
diaspora::send_mail($item,$owner,$contact);
|
||||||
|
//diaspora_send_mail($item,$owner,$contact);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$normal_mode)
|
if (!$normal_mode)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if((! $contact['pubkey']) && (! $public_message))
|
if (!$contact['pubkey'] && !$public_message)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
$unsupported_activities = array(ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
|
$unsupported_activities = array(ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
|
||||||
|
@ -523,22 +524,25 @@ function delivery_run(&$argv, &$argc){
|
||||||
// top-level retraction
|
// top-level retraction
|
||||||
logger('delivery: diaspora retract: '.$loc);
|
logger('delivery: diaspora retract: '.$loc);
|
||||||
|
|
||||||
diaspora_send_retraction($target_item,$owner,$contact,$public_message);
|
diaspora::send_retraction($target_item,$owner,$contact,$public_message);
|
||||||
|
//diaspora_send_retraction($target_item,$owner,$contact,$public_message);
|
||||||
break;
|
break;
|
||||||
} elseif ($followup) {
|
} elseif ($followup) {
|
||||||
// send comments and likes to owner to relay
|
// send comments and likes to owner to relay
|
||||||
diaspora_send_followup($target_item,$owner,$contact,$public_message);
|
diaspora::send_followup($target_item,$owner,$contact,$public_message);
|
||||||
|
//diaspora_send_followup($target_item,$owner,$contact,$public_message);
|
||||||
break;
|
break;
|
||||||
} elseif ($target_item['uri'] !== $target_item['parent-uri']) {
|
} elseif ($target_item['uri'] !== $target_item['parent-uri']) {
|
||||||
// we are the relay - send comments, likes and relayable_retractions to our conversants
|
// we are the relay - send comments, likes and relayable_retractions to our conversants
|
||||||
logger('delivery: diaspora relay: '.$loc);
|
logger('delivery: diaspora relay: '.$loc);
|
||||||
|
diaspora::send_relay($target_item,$owner,$contact,$public_message);
|
||||||
diaspora_send_relay($target_item,$owner,$contact,$public_message);
|
//diaspora_send_relay($target_item,$owner,$contact,$public_message);
|
||||||
break;
|
break;
|
||||||
} elseif(($top_level) && (! $walltowall)) {
|
} elseif ($top_level && !$walltowall) {
|
||||||
// currently no workable solution for sending walltowall
|
// currently no workable solution for sending walltowall
|
||||||
logger('delivery: diaspora status: '.$loc);
|
logger('delivery: diaspora status: '.$loc);
|
||||||
diaspora_send_status($target_item,$owner,$contact,$public_message);
|
diaspora::send_status($target_item,$owner,$contact,$public_message);
|
||||||
|
//diaspora_send_status($target_item,$owner,$contact,$public_message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ require_once('include/lock.php');
|
||||||
require_once('include/threads.php');
|
require_once('include/threads.php');
|
||||||
require_once('mod/share.php');
|
require_once('mod/share.php');
|
||||||
require_once('include/enotify.php');
|
require_once('include/enotify.php');
|
||||||
|
require_once('include/diaspora2.php');
|
||||||
|
|
||||||
function diaspora_dispatch_public($msg) {
|
function diaspora_dispatch_public($msg) {
|
||||||
|
|
||||||
|
|
|
@ -284,6 +284,8 @@ class diaspora {
|
||||||
|
|
||||||
$type = $fields->getName();
|
$type = $fields->getName();
|
||||||
|
|
||||||
|
logger("Received message type ".$type." from ".$sender." for user ".$importer["uid"], LOGGER_DEBUG);
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case "account_deletion":
|
case "account_deletion":
|
||||||
return self::receive_account_deletion($importer, $fields);
|
return self::receive_account_deletion($importer, $fields);
|
||||||
|
@ -654,7 +656,7 @@ class diaspora {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self::post_allow($importer, $contact, false)) {
|
if (!self::post_allow($importer, $contact, $is_comment)) {
|
||||||
logger("The handle: ".$handle." is not allowed to post to user ".$importer["uid"]);
|
logger("The handle: ".$handle." is not allowed to post to user ".$importer["uid"]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -669,10 +671,10 @@ class diaspora {
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
logger("message ".$guid." already exists for user ".$uid);
|
logger("message ".$guid." already exists for user ".$uid);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fetch_guid($item) {
|
private function fetch_guid($item) {
|
||||||
|
@ -774,11 +776,13 @@ class diaspora {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$r) {
|
if (!$r) {
|
||||||
logger("parent item not found: parent: ".$guid." item: ".$guid);
|
logger("parent item not found: parent: ".$guid." - user: ".$uid);
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else {
|
||||||
|
logger("parent item found: parent: ".$guid." - user: ".$uid);
|
||||||
return $r[0];
|
return $r[0];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function author_contact_by_url($contact, $person, $uid) {
|
private function author_contact_by_url($contact, $person, $uid) {
|
||||||
|
|
||||||
|
@ -892,6 +896,9 @@ class diaspora {
|
||||||
|
|
||||||
$message_id = item_store($datarray);
|
$message_id = item_store($datarray);
|
||||||
|
|
||||||
|
if ($message_id)
|
||||||
|
logger("Stored comment ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
|
||||||
|
|
||||||
// If we are the origin of the parent we store the original data and notify our followers
|
// If we are the origin of the parent we store the original data and notify our followers
|
||||||
if($message_id AND $parent_item["origin"]) {
|
if($message_id AND $parent_item["origin"]) {
|
||||||
|
|
||||||
|
@ -1175,6 +1182,9 @@ class diaspora {
|
||||||
|
|
||||||
$message_id = item_store($datarray);
|
$message_id = item_store($datarray);
|
||||||
|
|
||||||
|
if ($message_id)
|
||||||
|
logger("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
|
||||||
|
|
||||||
// If we are the origin of the parent we store the original data and notify our followers
|
// If we are the origin of the parent we store the original data and notify our followers
|
||||||
if($message_id AND $parent_item["origin"]) {
|
if($message_id AND $parent_item["origin"]) {
|
||||||
|
|
||||||
|
@ -1358,6 +1368,8 @@ class diaspora {
|
||||||
|
|
||||||
update_gcontact($gcontact);
|
update_gcontact($gcontact);
|
||||||
|
|
||||||
|
logger("Profile of contact ".$contact["id"]." stored for user ".$importer["uid"], LOGGER_DEBUG);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1654,6 +1666,9 @@ class diaspora {
|
||||||
self::fetch_guid($datarray);
|
self::fetch_guid($datarray);
|
||||||
$message_id = item_store($datarray);
|
$message_id = item_store($datarray);
|
||||||
|
|
||||||
|
if ($message_id)
|
||||||
|
logger("Stored reshare ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
|
||||||
|
|
||||||
return $message_id;
|
return $message_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1695,6 +1710,8 @@ class diaspora {
|
||||||
);
|
);
|
||||||
delete_thread($r[0]["id"], $r[0]["parent-uri"]);
|
delete_thread($r[0]["id"], $r[0]["parent-uri"]);
|
||||||
|
|
||||||
|
logger("Deleted target ".$target_guid." from user ".$importer["uid"], LOGGER_DEBUG);
|
||||||
|
|
||||||
// Now check if the retraction needs to be relayed by us
|
// Now check if the retraction needs to be relayed by us
|
||||||
if($p[0]["origin"]) {
|
if($p[0]["origin"]) {
|
||||||
|
|
||||||
|
@ -1822,7 +1839,8 @@ class diaspora {
|
||||||
self::fetch_guid($datarray);
|
self::fetch_guid($datarray);
|
||||||
$message_id = item_store($datarray);
|
$message_id = item_store($datarray);
|
||||||
|
|
||||||
logger("Stored item with message id ".$message_id, LOGGER_DEBUG);
|
if ($message_id)
|
||||||
|
logger("Stored item ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
|
||||||
|
|
||||||
return $message_id;
|
return $message_id;
|
||||||
}
|
}
|
||||||
|
@ -2329,8 +2347,21 @@ class diaspora {
|
||||||
/// @todo Change all signatur storing functions to the new format
|
/// @todo Change all signatur storing functions to the new format
|
||||||
if ($signature['signed_text'] AND $signature['signature'] AND $signature['signer'])
|
if ($signature['signed_text'] AND $signature['signature'] AND $signature['signer'])
|
||||||
$message = self::message_from_signatur($item, $signature);
|
$message = self::message_from_signatur($item, $signature);
|
||||||
else // New way
|
else {// New way
|
||||||
$message = json_decode($signature['signed_text']);
|
$msg = json_decode($signature['signed_text'], true);
|
||||||
|
|
||||||
|
$message = array();
|
||||||
|
foreach ($msg AS $field => $data) {
|
||||||
|
if (!$item["deleted"]) {
|
||||||
|
if ($field == "author")
|
||||||
|
$field = "diaspora_handle";
|
||||||
|
if ($field == "parent_type")
|
||||||
|
$field = "target_type";
|
||||||
|
}
|
||||||
|
|
||||||
|
$message[$field] = $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($item["deleted"]) {
|
if ($item["deleted"]) {
|
||||||
$signed_text = $message["target_guid"].';'.$message["target_type"];
|
$signed_text = $message["target_guid"].';'.$message["target_type"];
|
||||||
|
@ -2338,6 +2369,8 @@ class diaspora {
|
||||||
} else
|
} else
|
||||||
$message["parent_author_signature"] = self::signature($owner, $message);
|
$message["parent_author_signature"] = self::signature($owner, $message);
|
||||||
|
|
||||||
|
logger("Relayed data ".print_r($message, true), LOGGER_DEBUG);
|
||||||
|
|
||||||
return self::build_and_transmit($owner, $contact, $type, $message, $public_batch, $item["guid"]);
|
return self::build_and_transmit($owner, $contact, $type, $message, $public_batch, $item["guid"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,8 @@ function receive_post(&$a) {
|
||||||
|
|
||||||
logger('mod-diaspora: message is okay', LOGGER_DEBUG);
|
logger('mod-diaspora: message is okay', LOGGER_DEBUG);
|
||||||
|
|
||||||
$msg = diaspora_decode($importer,$xml);
|
$msg = diaspora::decode($importer,$xml);
|
||||||
|
//$msg = diaspora_decode($importer,$xml);
|
||||||
|
|
||||||
logger('mod-diaspora: decoded', LOGGER_DEBUG);
|
logger('mod-diaspora: decoded', LOGGER_DEBUG);
|
||||||
|
|
||||||
|
@ -65,10 +66,13 @@ function receive_post(&$a) {
|
||||||
logger('mod-diaspora: dispatching', LOGGER_DEBUG);
|
logger('mod-diaspora: dispatching', LOGGER_DEBUG);
|
||||||
|
|
||||||
$ret = 0;
|
$ret = 0;
|
||||||
if($public)
|
if($public) {
|
||||||
diaspora_dispatch_public($msg);
|
diaspora::dispatch_public($msg);
|
||||||
else
|
//diaspora_dispatch_public($msg);
|
||||||
$ret = diaspora_dispatch($importer,$msg);
|
} else {
|
||||||
|
$ret = diaspora::dispatch($importer,$msg);
|
||||||
|
//$ret = diaspora_dispatch($importer,$msg);
|
||||||
|
}
|
||||||
|
|
||||||
http_status_exit(($ret) ? $ret : 200);
|
http_status_exit(($ret) ? $ret : 200);
|
||||||
// NOTREACHED
|
// NOTREACHED
|
||||||
|
|
Loading…
Reference in New Issue
Block a user