aboutsummaryrefslogtreecommitdiffstats
path: root/mod/post.php
diff options
context:
space:
mode:
authormrjive <mrjive@mrjive.it>2015-01-06 15:13:03 +0100
committermrjive <mrjive@mrjive.it>2015-01-06 15:13:03 +0100
commitb80c218606994032e76805900cb9b340ea132358 (patch)
treebf625cf4c59bf521e639018399bf1770d116a6a0 /mod/post.php
parentaa6d61d3b19cb13c30bf5a1579adefedf0cc9515 (diff)
parent3185bfe3ca131d471b8fcdc0c94abf1a114486c7 (diff)
downloadvolse-hubzilla-b80c218606994032e76805900cb9b340ea132358.tar.gz
volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.tar.bz2
volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.zip
Merge pull request #1 from friendica/master
test pull request
Diffstat (limited to 'mod/post.php')
-rw-r--r--mod/post.php51
1 files changed, 38 insertions, 13 deletions
diff --git a/mod/post.php b/mod/post.php
index 3b4f66baf..9e818a7e2 100644
--- a/mod/post.php
+++ b/mod/post.php
@@ -98,7 +98,7 @@ function post_init(&$a) {
// Any channel will do, providing it's currently active. We just need to have an
// identity to attach to the packet we send back. So find one.
- $c = q("select * from channel where not ( channel_pageflags & %d ) limit 1",
+ $c = q("select * from channel where not ( channel_pageflags & %d )>0 limit 1",
intval(PAGE_REMOVED)
);
@@ -415,8 +415,8 @@ function post_init(&$a) {
* }
*}
*
- * Currently defined message types are 'activity', 'mail', 'profile' and 'channel_sync', which each have
- * different content schemas.
+ * Currently defined message types are 'activity', 'mail', 'profile', 'location' and 'channel_sync',
+ * which each have different content schemas.
*
* Ping packet:
* A ping packet does not require any parameters except the type. It may or may not be encrypted.
@@ -507,6 +507,7 @@ function post_post(&$a) {
json_return_and_die($ret);
}
+
if($msgtype === 'pickup') {
/**
@@ -597,11 +598,24 @@ function post_post(&$a) {
$ret['success'] = true;
$ret['pickup'] = array();
foreach($r as $rr) {
- $ret['pickup'][] = array('notify' => json_decode($rr['outq_notify'],true),'message' => json_decode($rr['outq_msg'],true));
+ if($rr['outq_msg']) {
+ $x = json_decode($rr['outq_msg'],true);
- $x = q("delete from outq where outq_hash = '%s' limit 1",
- dbesc($rr['outq_hash'])
- );
+ if(! $x)
+ continue;
+
+ if(array_key_exists('message_list',$x)) {
+ foreach($x['message_list'] as $xx) {
+ $ret['pickup'][] = array('notify' => json_decode($rr['outq_notify'],true),'message' => $xx);
+ }
+ }
+ else
+ $ret['pickup'][] = array('notify' => json_decode($rr['outq_notify'],true),'message' => $x);
+
+ $x = q("delete from outq where outq_hash = '%s'",
+ dbesc($rr['outq_hash'])
+ );
+ }
}
}
@@ -645,7 +659,7 @@ function post_post(&$a) {
// Update our DB to show when we last communicated successfully with this hub
// This will allow us to prune dead hubs from using up resources
- $r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d limit 1",
+ $r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d",
dbesc(datetime_convert()),
intval($hub['hubloc_id'])
);
@@ -653,17 +667,17 @@ function post_post(&$a) {
// a dead hub came back to life - reset any tombstones we might have
if($hub['hubloc_status'] & HUBLOC_OFFLINE) {
- q("update hubloc set hubloc_status = (hubloc_status ^ %d) where hubloc_id = %d limit 1",
+ q("update hubloc set hubloc_status = (hubloc_status & ~%d) where hubloc_id = %d",
intval(HUBLOC_OFFLINE),
intval($hub['hubloc_id'])
);
if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) {
- q("update hubloc set hubloc_flags = (hubloc_flags ^ %d) where hubloc_id = %d limit 1",
+ q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where hubloc_id = %d",
intval(HUBLOC_FLAGS_ORPHANCHECK),
intval($hub['hubloc_id'])
);
}
- q("update xchan set xchan_flags = (xchan_flags ^ %d) where (xchan_flags & %d) and xchan_hash = '%s' limit 1",
+ q("update xchan set xchan_flags = (xchan_flags & ~%d) where (xchan_flags & %d)>0 and xchan_hash = '%s'",
intval(XCHAN_FLAGS_ORPHAN),
intval(XCHAN_FLAGS_ORPHAN),
dbesc($hub['hubloc_hash'])
@@ -718,7 +732,9 @@ function post_post(&$a) {
$sender_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']);
// garbage collect any old unused notifications
- q("delete from verify where type = 'auth' and created < UTC_TIMESTAMP() - INTERVAL 10 MINUTE");
+ q("delete from verify where type = 'auth' and created < %s - INTERVAL %s",
+ db_utcnow(), db_quoteinterval('10 MINUTE')
+ );
$y = q("select xchan_pubkey from xchan where xchan_hash = '%s' limit 1",
dbesc($sender_hash)
@@ -767,7 +783,7 @@ function post_post(&$a) {
$ret['message'] .= 'verification key not found' . EOL;
json_return_and_die($ret);
}
- $r = q("delete from verify where id = %d limit 1",
+ $r = q("delete from verify where id = %d",
intval($z[0]['id'])
);
@@ -782,6 +798,7 @@ function post_post(&$a) {
$ret['service_class'] = $u[0]['account_service_class'];
// Set "do not track" flag if this site or this channel's profile is restricted
+ // in some way
if(intval(get_config('system','block_public')))
$ret['DNT'] = true;
@@ -789,6 +806,8 @@ function post_post(&$a) {
$ret['DNT'] = true;
if(get_pconfig($c[0]['channel_id'],'system','do_not_track'))
$ret['DNT'] = true;
+ if(get_pconfig($c[0]['channel_id'],'system','hide_online_status'))
+ $ret['DNT'] = true;
json_return_and_die($ret);
@@ -796,6 +815,12 @@ function post_post(&$a) {
json_return_and_die($ret);
}
+ if($msgtype === 'request') {
+ // request a particular post/conversation by message_id
+ $x = zot_process_message_request($data);
+ json_return_and_die($x);
+ }
+
if($msgtype === 'purge') {
if($recipients) {