Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 832 lines (655 sloc) 25.786 kb
6348e70 projectred Initial checkin
projectred authored
1 <?php
2
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
3 /*
4 * Module: dfrn_confirm
5 * Purpose: Friendship acceptance for DFRN contacts
6 *
7 * There are two possible entry points and three scenarios.
8 *
9 * 1. A form was submitted by our user approving a friendship that originated elsewhere.
10 * This may also be called from dfrn_request to automatically approve a friendship.
11 *
12 * 2. We may be the target or other side of the conversation to scenario 1, and will
13 * interact with that process on our own user's behalf.
14 *
15 */
e0b392b friendica add a bit more logging to friend accept
friendika authored
16
0f47ac2 projectred celebrity/group/community pages about 75% implemented
projectred authored
17 function dfrn_confirm_post(&$a,$handsfree = null) {
99a903e projectred better intro text
projectred authored
18
0f47ac2 projectred celebrity/group/community pages about 75% implemented
projectred authored
19 if(is_array($handsfree)) {
20
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
21 /**
22 * We were called directly from dfrn_request due to automatic friend acceptance.
23 * Any $_POST parameters we may require are supplied in the $handsfree array.
24 *
25 */
0f47ac2 projectred celebrity/group/community pages about 75% implemented
projectred authored
26
27 $node = $handsfree['node'];
28 $a->interactive = false; // notice() becomes a no-op since nobody is there to see it
29
30 }
31 else {
32 if($a->argc > 1)
33 $node = $a->argv[1];
34 }
6348e70 projectred Initial checkin
projectred authored
35
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
36 /**
37 *
38 * Main entry point. Scenario 1. Our user received a friend request notification (perhaps
39 * from another site) and clicked 'Approve'.
40 * $POST['source_url'] is not set. If it is, it indicates Scenario 2.
41 *
42 * We may also have been called directly from dfrn_request ($handsfree != null) due to
43 * this being a page type which supports automatic friend acceptance. That is also Scenario 1
44 * since we are operating on behalf of our registered user to approve a friendship.
45 *
46 */
6348e70 projectred Initial checkin
projectred authored
47
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
48 if(! x($_POST,'source_url')) {
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
49
ac824fe projectred eradicate redundant get_uid function
projectred authored
50 $uid = ((is_array($handsfree)) ? $handsfree['uid'] : local_user());
6348e70 projectred Initial checkin
projectred authored
51
52 if(! $uid) {
8424f31 projectred a bit more robust about loading external pics
projectred authored
53 notice( t('Permission denied.') . EOL );
6348e70 projectred Initial checkin
projectred authored
54 return;
55 }
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
56
0f47ac2 projectred celebrity/group/community pages about 75% implemented
projectred authored
57 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
58 intval($uid)
59 );
60
61 if(! $user) {
62 notice( t('Profile not found.') . EOL );
63 return;
64 }
65
6348e70 projectred Initial checkin
projectred authored
66
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
67 // These data elements may come from either the friend request notification form or $handsfree array.
0f47ac2 projectred celebrity/group/community pages about 75% implemented
projectred authored
68
69 if(is_array($handsfree)) {
ef39bd0 friendica more dfrn_confirm logging
friendika authored
70 logger('dfrn_confirm: Confirm in handsfree mode');
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
71 $dfrn_id = $handsfree['dfrn_id'];
72 $intro_id = $handsfree['intro_id'];
73 $duplex = $handsfree['duplex'];
c735582 RedMatrix hide contacts on approval
authored
74 $hidden = ((array_key_exists('hidden',$handsfree)) ? intval($handsfree['hidden']) : 0 );
76308ec RedMatrix add toggle to choose sending "friends with" activity even if contact is ...
authored
75 $activity = ((array_key_exists('activity',$handsfree)) ? intval($handsfree['activity']) : 0 );
0f47ac2 projectred celebrity/group/community pages about 75% implemented
projectred authored
76 }
77 else {
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
78 $dfrn_id = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : "");
79 $intro_id = ((x($_POST,'intro_id')) ? intval($_POST['intro_id']) : 0 );
80 $duplex = ((x($_POST,'duplex')) ? intval($_POST['duplex']) : 0 );
81 $cid = ((x($_POST,'contact_id')) ? intval($_POST['contact_id']) : 0 );
c735582 RedMatrix hide contacts on approval
authored
82 $hidden = ((x($_POST,'hidden')) ? intval($_POST['hidden']) : 0 );
76308ec RedMatrix add toggle to choose sending "friends with" activity even if contact is ...
authored
83 $activity = ((x($_POST,'activity')) ? intval($_POST['activity']) : 0 );
0f47ac2 projectred celebrity/group/community pages about 75% implemented
projectred authored
84 }
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
85
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
86 /**
87 *
88 * Ensure that dfrn_id has precedence when we go to find the contact record.
89 * We only want to search based on contact id if there is no dfrn_id,
90 * e.g. for OStatus network followers.
91 *
92 */
93
94 if(strlen($dfrn_id))
95 $cid = 0;
96
ef39bd0 friendica more dfrn_confirm logging
friendika authored
97 logger('dfrn_confirm: Confirming request for dfrn_id (issued) ' . $dfrn_id);
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
98 if($cid)
99 logger('dfrn_confirm: Confirming follower with contact_id: ' . $cid);
ef39bd0 friendica more dfrn_confirm logging
friendika authored
100
e0b392b friendica add a bit more logging to friend accept
friendika authored
101
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
102 /**
103 *
104 * The other person will have been issued an ID when they first requested friendship.
105 * Locate their record. At this time, their record will have both pending and blocked set to 1.
106 * There won't be any dfrn_id if this is a network follower, so use the contact_id instead.
107 *
108 */
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
109
60ae0d8 RedMatrix cleaned up mess created when both people request friendship and one appr...
authored
110 $r = q("SELECT * FROM `contact` WHERE ( ( `issued-id` != '' AND `issued-id` = '%s' ) OR ( `id` = %d AND `id` != 0 ) ) AND `uid` = %d AND `duplex` = 0 LIMIT 1",
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
111 dbesc($dfrn_id),
112 intval($cid),
113 intval($uid)
0ddfdce projectred make it much easier to debug friend acceptance issues
projectred authored
114 );
6348e70 projectred Initial checkin
projectred authored
115
ffb1997 projectred mistpark 2.0 infrasturcture lands
projectred authored
116 if(! count($r)) {
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
117 logger('dfrn_confirm: Contact not found in DB.');
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
118 notice( t('Contact not found.') . EOL );
60ae0d8 RedMatrix cleaned up mess created when both people request friendship and one appr...
authored
119 notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL );
6348e70 projectred Initial checkin
projectred authored
120 return;
121 }
122
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
123 $contact = $r[0];
6348e70 projectred Initial checkin
projectred authored
124
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
125 $contact_id = $contact['id'];
126 $relation = $contact['rel'];
127 $site_pubkey = $contact['site-pubkey'];
128 $dfrn_confirm = $contact['confirm'];
129 $aes_allow = $contact['aes_allow'];
c735582 RedMatrix hide contacts on approval
authored
130
a6d88fb friendica diaspora friend approvals
friendika authored
131 $network = ((strlen($contact['issued-id'])) ? NETWORK_DFRN : NETWORK_OSTATUS);
132
fcf6651 friendica add diaspora support to dfrn_confirm (friendship confirmation)
friendika authored
133 if($contact['network'])
134 $network = $contact['network'];
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
135
a6d88fb friendica diaspora friend approvals
friendika authored
136 if($network === NETWORK_DFRN) {
6348e70 projectred Initial checkin
projectred authored
137
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
138 /**
139 *
140 * Generate a key pair for all further communications with this person.
141 * We have a keypair for every contact, and a site key for unknown people.
142 * This provides a means to carry on relationships with other people if
143 * any single key is compromised. It is a robust key. We're much more
144 * worried about key leakage than anybody cracking it.
145 *
146 */
afaf9ec RedMatrix rev update
authored
147 require_once('include/crypto.php');
6348e70 projectred Initial checkin
projectred authored
148
7f3813e RedMatrix service class basics
authored
149 $res = new_keypair(4096);
6348e70 projectred Initial checkin
projectred authored
150
afaf9ec RedMatrix rev update
authored
151 $private_key = $res['prvkey'];
152 $public_key = $res['pubkey'];
6348e70 projectred Initial checkin
projectred authored
153
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
154 // Save the private key. Send them the public key.
6348e70 projectred Initial checkin
projectred authored
155
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
156 $r = q("UPDATE `contact` SET `prvkey` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
157 dbesc($private_key),
158 intval($contact_id),
159 intval($uid)
160 );
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
161
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
162 $params = array();
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
163
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
164 /**
165 *
166 * Per the DFRN protocol, we will verify both ends by encrypting the dfrn_id with our
167 * site private key (person on the other end can decrypt it with our site public key).
168 * Then encrypt our profile URL with the other person's site public key. They can decrypt
169 * it with their site private key. If the decryption on the other end fails for either
170 * item, it indicates tampering or key failure on at least one site and we will not be
171 * able to provide a secure communication pathway.
172 *
173 * If other site is willing to accept full encryption, (aes_allow is 1 AND we have php5.3
174 * or later) then we encrypt the personal public key we send them using AES-256-CBC and a
175 * random key which is encrypted with their site public key.
176 *
177 */
6348e70 projectred Initial checkin
projectred authored
178
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
179 $src_aes_key = random_string();
6348e70 projectred Initial checkin
projectred authored
180
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
181 $result = '';
182 openssl_private_encrypt($dfrn_id,$result,$user[0]['prvkey']);
6348e70 projectred Initial checkin
projectred authored
183
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
184 $params['dfrn_id'] = bin2hex($result);
185 $params['public_key'] = $public_key;
0ddfdce projectred make it much easier to debug friend acceptance issues
projectred authored
186
6348e70 projectred Initial checkin
projectred authored
187
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
188 $my_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
6348e70 projectred Initial checkin
projectred authored
189
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
190 openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
191 $params['source_url'] = bin2hex($params['source_url']);
ffb1997 projectred mistpark 2.0 infrasturcture lands
projectred authored
192
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
193 if($aes_allow && function_exists('openssl_encrypt')) {
194 openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey);
195 $params['aes_key'] = bin2hex($params['aes_key']);
196 $params['public_key'] = bin2hex(openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key));
197 }
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
198
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
199 $params['dfrn_version'] = DFRN_PROTOCOL_VERSION ;
200 if($duplex == 1)
201 $params['duplex'] = 1;
6348e70 projectred Initial checkin
projectred authored
202
5d10672 RedMatrix fix join group notifications
authored
203 if($user[0]['page-flags'] == PAGE_COMMUNITY)
7684f63 RedMatrix track whether contact is a community page or not
authored
204 $params['page'] = 1;
88a0d6a RedMatrix private group tests, cont.
authored
205 if($user[0]['page-flags'] == PAGE_PRVGROUP)
206 $params['page'] = 2;
7684f63 RedMatrix track whether contact is a community page or not
authored
207
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
208 logger('dfrn_confirm: Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA);
e0b392b friendica add a bit more logging to friend accept
friendika authored
209
9fb0bd5 friendica Raise network timeout during friend acceptance, because
friendika authored
210 /**
211 *
212 * POST all this stuff to the other site.
213 * Temporarily raise the network timeout to 120 seconds because the default 60
214 * doesn't always give the other side quite enough time to decrypt everything.
215 *
216 */
217
218 $a->config['system']['curl_timeout'] = 120;
6348e70 projectred Initial checkin
projectred authored
219
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
220 $res = post_url($dfrn_confirm,$params);
036964d projectred friend acceptance sets up lots of important stuff, so we
projectred authored
221
e0b392b friendica add a bit more logging to friend accept
friendika authored
222 logger('dfrn_confirm: Confirm: received data: ' . $res, LOGGER_DATA);
223
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
224 // Now figure out what they responded. Try to be robust if the remote site is
225 // having difficulty and throwing up errors of some kind.
036964d projectred friend acceptance sets up lots of important stuff, so we
projectred authored
226
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
227 $leading_junk = substr($res,0,strpos($res,'<?xml'));
036964d projectred friend acceptance sets up lots of important stuff, so we
projectred authored
228
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
229 $res = substr($res,strpos($res,'<?xml'));
230 if(! strlen($res)) {
036964d projectred friend acceptance sets up lots of important stuff, so we
projectred authored
231
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
232 // No XML at all, this exchange is messed up really bad.
233 // We shouldn't proceed, because the xml parser might choke,
234 // and $status is going to be zero, which indicates success.
235 // We can hardly call this a success.
236
237 notice( t('Response from remote site was not understood.') . EOL);
238 return;
239 }
036964d projectred friend acceptance sets up lots of important stuff, so we
projectred authored
240
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
241 if(strlen($leading_junk) && get_config('system','debugging')) {
242
243 // This might be more common. Mixed error text and some XML.
244 // If we're configured for debugging, show the text. Proceed in either case.
036964d projectred friend acceptance sets up lots of important stuff, so we
projectred authored
245
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
246 notice( t('Unexpected response from remote site: ') . EOL . $leading_junk . EOL );
247 }
6348e70 projectred Initial checkin
projectred authored
248
793967a friendica better handling of troublesome feeds.
friendika authored
249 $xml = parse_xml_string($res);
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
250 $status = (int) $xml->status;
251 $message = unxmlify($xml->message); // human readable text of what may have gone wrong.
252 switch($status) {
253 case 0:
dd09c2d fabrixxm use info() for successfull dfrn confirmation instead of notice()
fabrixxm authored
254 info( t("Confirmation completed successfully.") . EOL);
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
255 if(strlen($message))
256 notice( t('Remote site reported: ') . $message . EOL);
257 break;
258 case 1:
259 // birthday paradox - generate new dfrn-id and fall through.
260 $new_dfrn_id = random_string();
261 $r = q("UPDATE contact SET `issued-id` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
262 dbesc($new_dfrn_id),
263 intval($contact_id),
264 intval($uid)
265 );
266
267 case 2:
268 notice( t("Temporary failure. Please wait and try again.") . EOL);
269 if(strlen($message))
270 notice( t('Remote site reported: ') . $message . EOL);
271 break;
272
273
274 case 3:
275 notice( t("Introduction failed or was revoked.") . EOL);
276 if(strlen($message))
277 notice( t('Remote site reported: ') . $message . EOL);
278 break;
279 }
280
281 if(($status == 0) && ($intro_id)) {
282
283 // Success. Delete the notification.
284
285 $r = q("DELETE FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1",
286 intval($intro_id),
287 intval($uid)
6348e70 projectred Initial checkin
projectred authored
288 );
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
289
036964d projectred friend acceptance sets up lots of important stuff, so we
projectred authored
290 }
6348e70 projectred Initial checkin
projectred authored
291
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
292 if($status != 0)
293 return;
6348e70 projectred Initial checkin
projectred authored
294 }
036964d projectred friend acceptance sets up lots of important stuff, so we
projectred authored
295
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
296
297 /*
298 *
299 * We have now established a relationship with the other site.
300 * Let's make our own personal copy of their profile photo so we don't have
301 * to always load it from their site.
302 *
303 * We will also update the contact record with the nature and scope of the relationship.
304 *
305 */
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
306
a589e8e friendica filename typo
friendika authored
307 require_once('include/Photo.php');
6348e70 projectred Initial checkin
projectred authored
308
d2e20d0 projectred de-duplicate photo importation logic
projectred authored
309 $photos = import_profile_photo($contact['photo'],$uid,$contact_id);
e0b392b friendica add a bit more logging to friend accept
friendika authored
310
311 logger('dfrn_confirm: confirm - imported photos');
ffb1997 projectred mistpark 2.0 infrasturcture lands
projectred authored
312
a6d88fb friendica diaspora friend approvals
friendika authored
313 if($network === NETWORK_DFRN) {
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
314
48ffa88 friendica cleanup
friendika authored
315 $new_relation = CONTACT_IS_FOLLOWER;
316 if(($relation == CONTACT_IS_SHARING) || ($duplex))
317 $new_relation = CONTACT_IS_FRIEND;
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
318
48ffa88 friendica cleanup
friendika authored
319 if(($relation == CONTACT_IS_SHARING) && ($duplex))
70bcf00 friendica if pre-existing relationship, don't set duplex
friendika authored
320 $duplex = 0;
321
c735582 RedMatrix hide contacts on approval
authored
322 $r = q("UPDATE `contact` SET
323 `photo` = '%s',
b94cb8d friendica add micro profile photo
friendika authored
324 `thumb` = '%s',
325 `micro` = '%s',
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
326 `rel` = %d,
327 `name-date` = '%s',
328 `uri-date` = '%s',
329 `avatar-date` = '%s',
330 `blocked` = 0,
331 `pending` = 0,
332 `duplex` = %d,
c735582 RedMatrix hide contacts on approval
authored
333 `hidden` = %d,
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
334 `network` = 'dfrn' WHERE `id` = %d LIMIT 1
335 ",
d2e20d0 projectred de-duplicate photo importation logic
projectred authored
336 dbesc($photos[0]),
337 dbesc($photos[1]),
b94cb8d friendica add micro profile photo
friendika authored
338 dbesc($photos[2]),
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
339 intval($new_relation),
340 dbesc(datetime_convert()),
341 dbesc(datetime_convert()),
342 dbesc(datetime_convert()),
343 intval($duplex),
c735582 RedMatrix hide contacts on approval
authored
344 intval($hidden),
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
345 intval($contact_id)
346 );
347 }
348 else {
349
a6d88fb friendica diaspora friend approvals
friendika authored
350 // $network !== NETWORK_DFRN
351
352 $network = (($contact['network']) ? $contact['network'] : NETWORK_OSTATUS);
fcf6651 friendica add diaspora support to dfrn_confirm (friendship confirmation)
friendika authored
353 $notify = (($contact['notify']) ? $contact['notify'] : '');
354 $poll = (($contact['poll']) ? $contact['poll'] : '');
355
356 if((! $contact['notify']) || (! $contact['poll'])) {
357 $arr = lrdd($contact['url']);
358 if(count($arr)) {
359 foreach($arr as $link) {
360 if($link['@attributes']['rel'] === 'salmon')
361 $notify = $link['@attributes']['href'];
362 if($link['@attributes']['rel'] === NAMESPACE_FEED)
363 $poll = $link['@attributes']['href'];
364 }
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
365 }
366 }
367
a6d88fb friendica diaspora friend approvals
friendika authored
368 $new_relation = $contact['rel'];
c05c20a friendica set writable (e.g. writeable) flag for Diaspora contacts
friendika authored
369 $writable = $contact['writable'];
370
371 if($network === NETWORK_DIASPORA) {
372 if($duplex)
373 $new_relation = CONTACT_IS_FRIEND;
4993f4f RedMatrix allow plugin to abort message posting, fix half-duplex D* relationship
authored
374 else
375 $new_relation = CONTACT_IS_SHARING;
376
c05c20a friendica set writable (e.g. writeable) flag for Diaspora contacts
friendika authored
377 if($new_relation != CONTACT_IS_FOLLOWER)
378 $writable = 1;
379 }
a6d88fb friendica diaspora friend approvals
friendika authored
380
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
381 $r = q("DELETE FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1",
382 intval($intro_id),
383 intval($uid)
384 );
385
a3ddbb5 friendica issues with friendship again
friendika authored
386
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
387 $r = q("UPDATE `contact` SET `photo` = '%s',
b94cb8d friendica add micro profile photo
friendika authored
388 `thumb` = '%s',
389 `micro` = '%s',
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
390 `name-date` = '%s',
391 `uri-date` = '%s',
392 `avatar-date` = '%s',
393 `notify` = '%s',
394 `poll` = '%s',
395 `blocked` = 0,
a3ddbb5 friendica issues with friendship again
friendika authored
396 `pending` = 0,
a6d88fb friendica diaspora friend approvals
friendika authored
397 `network` = '%s',
c05c20a friendica set writable (e.g. writeable) flag for Diaspora contacts
friendika authored
398 `writable` = %d,
c735582 RedMatrix hide contacts on approval
authored
399 `hidden` = %d,
a6d88fb friendica diaspora friend approvals
friendika authored
400 `rel` = %d
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
401 WHERE `id` = %d LIMIT 1
402 ",
d2e20d0 projectred de-duplicate photo importation logic
projectred authored
403 dbesc($photos[0]),
404 dbesc($photos[1]),
b94cb8d friendica add micro profile photo
friendika authored
405 dbesc($photos[2]),
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
406 dbesc(datetime_convert()),
407 dbesc(datetime_convert()),
408 dbesc(datetime_convert()),
409 dbesc($notify),
410 dbesc($poll),
3a0727d friendica set network correctly - dfrn_confirm
friendika authored
411 dbesc($network),
c05c20a friendica set writable (e.g. writeable) flag for Diaspora contacts
friendika authored
412 intval($writable),
c735582 RedMatrix hide contacts on approval
authored
413 intval($hidden),
a6d88fb friendica diaspora friend approvals
friendika authored
414 intval($new_relation),
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
415 intval($contact_id)
416 );
417 }
418
6348e70 projectred Initial checkin
projectred authored
419 if($r === false)
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
420 notice( t('Unable to set contact photo.') . EOL);
6d7b018 projectred minor edit to last commit
projectred authored
421
b302012 friendica send new friend activity when appropriate
friendika authored
422 // reload contact info
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
423
b302012 friendica send new friend activity when appropriate
friendika authored
424 $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
425 intval($contact_id)
426 );
427 if(count($r))
428 $contact = $r[0];
429 else
430 $contact = null;
431
432
3c0cf72 RedMatrix make 'aaa joined group bbb' work from the initiating end, new privacy pr...
authored
433 if((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
3ff8fe5 RedMatrix provide "xxx joined yyy" notifications
authored
434
3c0cf72 RedMatrix make 'aaa joined group bbb' work from the initiating end, new privacy pr...
authored
435 if(($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
a589e8e friendica filename typo
friendika authored
436 require_once('include/diaspora.php');
f7a1674 friendica set proper relation for diaspora in mod_follow
friendika authored
437 $ret = diaspora_share($user[0],$r[0]);
438 logger('mod_follow: diaspora_share returns: ' . $ret);
a6d88fb friendica diaspora friend approvals
friendika authored
439 }
440
76308ec RedMatrix add toggle to choose sending "friends with" activity even if contact is ...
authored
441 // Send a new friend post if we are allowed to...
b302012 friendica send new friend activity when appropriate
friendika authored
442
76308ec RedMatrix add toggle to choose sending "friends with" activity even if contact is ...
authored
443 $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
b302012 friendica send new friend activity when appropriate
friendika authored
444 intval($uid)
445 );
5d10672 RedMatrix fix join group notifications
authored
446
3c0cf72 RedMatrix make 'aaa joined group bbb' work from the initiating end, new privacy pr...
authored
447 if((count($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
b302012 friendica send new friend activity when appropriate
friendika authored
448
76308ec RedMatrix add toggle to choose sending "friends with" activity even if contact is ...
authored
449 require_once('include/items.php');
b302012 friendica send new friend activity when appropriate
friendika authored
450
76308ec RedMatrix add toggle to choose sending "friends with" activity even if contact is ...
authored
451 $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
452 intval($uid)
453 );
b302012 friendica send new friend activity when appropriate
friendika authored
454
76308ec RedMatrix add toggle to choose sending "friends with" activity even if contact is ...
authored
455 if(count($self)) {
456
457 $arr = array();
458 $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $uid);
459 $arr['uid'] = $uid;
460 $arr['contact-id'] = $self[0]['id'];
461 $arr['wall'] = 1;
462 $arr['type'] = 'wall';
463 $arr['gravity'] = 0;
464 $arr['origin'] = 1;
465 $arr['author-name'] = $arr['owner-name'] = $self[0]['name'];
466 $arr['author-link'] = $arr['owner-link'] = $self[0]['url'];
467 $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
3ff8fe5 RedMatrix provide "xxx joined yyy" notifications
authored
468
76308ec RedMatrix add toggle to choose sending "friends with" activity even if contact is ...
authored
469 $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]';
3ff8fe5 RedMatrix provide "xxx joined yyy" notifications
authored
470 $APhoto = '[url=' . $self[0]['url'] . ']' . '[img]' . $self[0]['thumb'] . '[/img][/url]';
471
76308ec RedMatrix add toggle to choose sending "friends with" activity even if contact is ...
authored
472 $B = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
473 $BPhoto = '[url=' . $contact['url'] . ']' . '[img]' . $contact['thumb'] . '[/img][/url]';
474
3c0cf72 RedMatrix make 'aaa joined group bbb' work from the initiating end, new privacy pr...
authored
475 $arr['verb'] = ACTIVITY_FRIEND;
476 $arr['object-type'] = ACTIVITY_OBJ_PERSON;
477 $arr['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$BPhoto;
3ff8fe5 RedMatrix provide "xxx joined yyy" notifications
authored
478
3c0cf72 RedMatrix make 'aaa joined group bbb' work from the initiating end, new privacy pr...
authored
479 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $contact['name'] . '</title>'
480 . '<id>' . $contact['url'] . '/' . $contact['name'] . '</id>';
481 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $contact['url'] . '" />' . "\n");
482 $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $contact['thumb'] . '" />' . "\n");
483 $arr['object'] .= '</link></object>' . "\n";
3ff8fe5 RedMatrix provide "xxx joined yyy" notifications
authored
484
76308ec RedMatrix add toggle to choose sending "friends with" activity even if contact is ...
authored
485 $arr['last-child'] = 1;
486
487 $arr['allow_cid'] = $user[0]['allow_cid'];
488 $arr['allow_gid'] = $user[0]['allow_gid'];
489 $arr['deny_cid'] = $user[0]['deny_cid'];
490 $arr['deny_gid'] = $user[0]['deny_gid'];
491
492 $i = item_store($arr);
493 if($i)
494 proc_run('php',"include/notifier.php","activity","$i");
495 }
496 }
b302012 friendica send new friend activity when appropriate
friendika authored
497 }
5ecaeb8 RedMatrix catch more places to apply default group
authored
498
499
500 $g = q("select def_gid from user where uid = %d limit 1",
501 intval($uid)
502 );
503 if($contact && $g && intval($g[0]['def_gid'])) {
504 require_once('include/group.php');
bb4712b RedMatrix bug #434 - default group placement not working after accepting dfrn frie...
authored
505 group_add_member($uid,'',$contact['id'],$g[0]['def_gid']);
5ecaeb8 RedMatrix catch more places to apply default group
authored
506 }
507
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
508 // Let's send our user to the contact editor in case they want to
509 // do anything special with this new friend.
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
510
0f47ac2 projectred celebrity/group/community pages about 75% implemented
projectred authored
511 if($handsfree === null)
512 goaway($a->get_baseurl() . '/contacts/' . intval($contact_id));
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
513 else
514 return;
515 //NOTREACHED
6348e70 projectred Initial checkin
projectred authored
516 }
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
517
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
518 /**
519 *
520 *
521 * End of Scenario 1. [Local confirmation of remote friend request].
522 *
523 * Begin Scenario 2. This is the remote response to the above scenario.
524 * This will take place on the site that originally initiated the friend request.
525 * In the section above where the confirming party makes a POST and
526 * retrieves xml status information, they are communicating with the following code.
527 *
528 */
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
529
530 if(x($_POST,'source_url')) {
531
532 // We are processing an external confirmation to an introduction created by our user.
533
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
534 $public_key = ((x($_POST,'public_key')) ? $_POST['public_key'] : '');
535 $dfrn_id = ((x($_POST,'dfrn_id')) ? hex2bin($_POST['dfrn_id']) : '');
536 $source_url = ((x($_POST,'source_url')) ? hex2bin($_POST['source_url']) : '');
537 $aes_key = ((x($_POST,'aes_key')) ? $_POST['aes_key'] : '');
538 $duplex = ((x($_POST,'duplex')) ? intval($_POST['duplex']) : 0 );
7684f63 RedMatrix track whether contact is a community page or not
authored
539 $page = ((x($_POST,'page')) ? intval($_POST['page']) : 0 );
4d0f0f9 friendica more instrumentation on dfrn_confirm to help track down why it quietly g...
friendika authored
540 $version_id = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
ef39bd0 friendica more dfrn_confirm logging
friendika authored
541
88a0d6a RedMatrix private group tests, cont.
authored
542 $forum = (($page == 1) ? 1 : 0);
543 $prv = (($page == 2) ? 1 : 0);
544
ef39bd0 friendica more dfrn_confirm logging
friendika authored
545 logger('dfrn_confirm: requestee contacted: ' . $node);
6b67d00 projectred if pubkey is encrypted, it will also be packaged for safe transport
projectred authored
546
e0b392b friendica add a bit more logging to friend accept
friendika authored
547 logger('dfrn_confirm: request: POST=' . print_r($_POST,true), LOGGER_DATA);
548
6b67d00 projectred if pubkey is encrypted, it will also be packaged for safe transport
projectred authored
549 // If $aes_key is set, both of these items require unpacking from the hex transport encoding.
550
551 if(x($aes_key)) {
552 $aes_key = hex2bin($aes_key);
553 $public_key = hex2bin($public_key);
554 }
555
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
556 // Find our user's account
557
558 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
559 dbesc($node));
560
561 if(! count($r)) {
9f78780 fabrixxm update source strings
fabrixxm authored
562 $message = sprintf(t('No user record found for \'%s\' '), $node);
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
563 xml_status(3,$message); // failure
564 // NOTREACHED
565 }
566
567 $my_prvkey = $r[0]['prvkey'];
568 $local_uid = $r[0]['uid'];
569
570
e320975 friendica bug #95
friendika authored
571 if(! strstr($my_prvkey,'PRIVATE KEY')) {
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
572 $message = t('Our site encryption key is apparently messed up.');
573 xml_status(3,$message);
574 }
575
576 // verify everything
577
578 $decrypted_source_url = "";
579 openssl_private_decrypt($source_url,$decrypted_source_url,$my_prvkey);
580
581
582 if(! strlen($decrypted_source_url)) {
583 $message = t('Empty site URL was provided or URL could not be decrypted by us.');
584 xml_status(3,$message);
585 // NOTREACHED
586 }
587
588 $ret = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
589 dbesc($decrypted_source_url),
590 intval($local_uid)
591 );
592 if(! count($ret)) {
fda593c friendica introduction fails if confirmation differs by http vs https
friendika authored
593 if(strstr($decrypted_source_url,'http:'))
594 $newurl = str_replace('http:','https:',$decrypted_source_url);
595 else
596 $newurl = str_replace('https:','http:',$decrypted_source_url);
597
598 $ret = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
599 dbesc($newurl),
600 intval($local_uid)
601 );
f17d918 friendica part of bug #143
friendika authored
602 if(! count($ret)) {
fda593c friendica introduction fails if confirmation differs by http vs https
friendika authored
603 // this is either a bogus confirmation (?) or we deleted the original introduction.
604 $message = t('Contact record was not found for you on our site.');
605 xml_status(3,$message);
606 return; // NOTREACHED
607 }
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
608 }
609
610 $relation = $ret[0]['rel'];
611
612 // Decrypt all this stuff we just received
613
614 $foreign_pubkey = $ret[0]['site-pubkey'];
615 $dfrn_record = $ret[0]['id'];
616
f17d918 friendica part of bug #143
friendika authored
617 if(! $foreign_pubkey) {
618 $message = sprintf( t('Site public key not available in contact record for URL %s.'), $newurl);
619 xml_status(3,$message);
620 }
621
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
622 $decrypted_dfrn_id = "";
623 openssl_public_decrypt($dfrn_id,$decrypted_dfrn_id,$foreign_pubkey);
624
625 if(strlen($aes_key)) {
626 $decrypted_aes_key = "";
627 openssl_private_decrypt($aes_key,$decrypted_aes_key,$my_prvkey);
628 $dfrn_pubkey = openssl_decrypt($public_key,'AES-256-CBC',$decrypted_aes_key);
629 }
630 else {
631 $dfrn_pubkey = $public_key;
632 }
633
634 $r = q("SELECT * FROM `contact` WHERE `dfrn-id` = '%s' LIMIT 1",
22f7ffc friendica enumerate required php modules
friendika authored
635 dbesc($decrypted_dfrn_id)
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
636 );
637 if(count($r)) {
638 $message = t('The ID provided by your system is a duplicate on our system. It should work if you try again.');
639 xml_status(1,$message); // Birthday paradox - duplicate dfrn-id
640 // NOTREACHED
641 }
642
643 $r = q("UPDATE `contact` SET `dfrn-id` = '%s', `pubkey` = '%s' WHERE `id` = %d LIMIT 1",
644 dbesc($decrypted_dfrn_id),
645 dbesc($dfrn_pubkey),
646 intval($dfrn_record)
647 );
648 if(! count($r)) {
649 $message = t('Unable to set your contact credentials on our system.');
650 xml_status(3,$message);
651 }
652
60ae0d8 RedMatrix cleaned up mess created when both people request friendship and one appr...
authored
653 // It's possible that the other person also requested friendship.
654 // If it is a duplex relationship, ditch the issued-id if one exists.
655
656 if($duplex) {
657 $r = q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d LIMIT 1",
658 intval($dfrn_record)
659 );
660 }
661
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
662 // We're good but now we have to scrape the profile photo and send notifications.
663
664
665
666 $r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1",
667 intval($dfrn_record));
668
d2e20d0 projectred de-duplicate photo importation logic
projectred authored
669 if(count($r))
670 $photo = $r[0]['photo'];
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
671 else
894278d RedMatrix change default profile photo to something more interesting than a reddis...
authored
672 $photo = $a->get_baseurl() . '/images/person-175.jpg';
d2e20d0 projectred de-duplicate photo importation logic
projectred authored
673
674 require_once("Photo.php");
675
676 $photos = import_profile_photo($photo,$local_uid,$dfrn_record);
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
677
e0b392b friendica add a bit more logging to friend accept
friendika authored
678 logger('dfrn_confirm: request - photos imported');
679
48ffa88 friendica cleanup
friendika authored
680 $new_relation = CONTACT_IS_SHARING;
681 if(($relation == CONTACT_IS_FOLLOWER) || ($duplex))
682 $new_relation = CONTACT_IS_FRIEND;
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
683
48ffa88 friendica cleanup
friendika authored
684 if(($relation == CONTACT_IS_FOLLOWER) && ($duplex))
70bcf00 friendica if pre-existing relationship, don't set duplex
friendika authored
685 $duplex = 0;
686
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
687 $r = q("UPDATE `contact` SET
688 `photo` = '%s',
689 `thumb` = '%s',
a3ddbb5 friendica issues with friendship again
friendika authored
690 `micro` = '%s',
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
691 `rel` = %d,
692 `name-date` = '%s',
693 `uri-date` = '%s',
694 `avatar-date` = '%s',
695 `blocked` = 0,
696 `pending` = 0,
697 `duplex` = %d,
7684f63 RedMatrix track whether contact is a community page or not
authored
698 `forum` = %d,
88a0d6a RedMatrix private group tests, cont.
authored
699 `prv` = %d,
c05c20a friendica set writable (e.g. writeable) flag for Diaspora contacts
friendika authored
700 `network` = '%s' WHERE `id` = %d LIMIT 1
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
701 ",
d2e20d0 projectred de-duplicate photo importation logic
projectred authored
702 dbesc($photos[0]),
703 dbesc($photos[1]),
a3ddbb5 friendica issues with friendship again
friendika authored
704 dbesc($photos[2]),
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
705 intval($new_relation),
706 dbesc(datetime_convert()),
707 dbesc(datetime_convert()),
708 dbesc(datetime_convert()),
709 intval($duplex),
88a0d6a RedMatrix private group tests, cont.
authored
710 intval($forum),
711 intval($prv),
c05c20a friendica set writable (e.g. writeable) flag for Diaspora contacts
friendika authored
712 dbesc(NETWORK_DFRN),
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
713 intval($dfrn_record)
714 );
b41218c projectred workflow for federated/non-dfrn followers
projectred authored
715 if($r === false) { // indicates schema is messed up or total db failure
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
716 $message = t('Unable to update your contact profile details on our system');
717 xml_status(3,$message);
718 }
719
720 // Otherwise everything seems to have worked and we are almost done. Yay!
721 // Send an email notification
722
ef39bd0 friendica more dfrn_confirm logging
friendika authored
723 logger('dfrn_confirm: request: info updated');
724
040fc24 friendica bug #85
friendika authored
725 $r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
726 WHERE `contact`.`id` = %d LIMIT 1",
727 intval($dfrn_record)
728 );
3c0cf72 RedMatrix make 'aaa joined group bbb' work from the initiating end, new privacy pr...
authored
729
730 if(count($r))
731 $combined = $r[0];
732
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
733 if((count($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
734
040fc24 friendica bug #85
friendika authored
735 push_lang($r[0]['language']);
48ffa88 friendica cleanup
friendika authored
736 $tpl = (($new_relation == CONTACT_IS_FRIEND)
b2e92e0 friendica deprecate load_view_file
friendika authored
737 ? get_intltext_template('friend_complete_eml.tpl')
738 : get_intltext_template('intro_complete_eml.tpl'));
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
739
740 $email_tpl = replace_macros($tpl, array(
741 '$sitename' => $a->config['sitename'],
742 '$siteurl' => $a->get_baseurl(),
743 '$username' => $r[0]['username'],
744 '$email' => $r[0]['email'],
745 '$fn' => $r[0]['name'],
746 '$dfrn_url' => $r[0]['url'],
747 '$uid' => $newuid )
748 );
749
a7af6df fabrixxm Fix spaces around t() and tt()
fabrixxm authored
750 $res = mail($r[0]['email'], sprintf( t("Connection accepted at %s") , $a->config['sitename']),
de131c9 friendica set utf-8 on all emails
friendika authored
751 $email_tpl,
752 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
753 . 'Content-type: text/plain; charset=UTF-8' . "\n"
754 . 'Content-transfer-encoding: 8bit' );
755
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
756 if(!$res) {
b9d7689 projectred added 's' keys - salmon keys, small keys, stupid keys, whatever...
projectred authored
757 // pointless throwing an error here and confusing the person at the other end of the wire.
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
758 }
040fc24 friendica bug #85
friendika authored
759 pop_lang();
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
760 }
3c0cf72 RedMatrix make 'aaa joined group bbb' work from the initiating end, new privacy pr...
authored
761
762 // Send a new friend post if we are allowed to...
763
764 if($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) {
765 $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
766 intval($local_uid)
767 );
768
769 if((count($r)) && ($r[0]['hide-friends'] == 0)) {
770
771 require_once('include/items.php');
772
773 $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
774 intval($local_uid)
775 );
776
777 if(count($self)) {
778
779 $arr = array();
780 $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid);
781 $arr['uid'] = $local_uid;
782 $arr['contact-id'] = $self[0]['id'];
783 $arr['wall'] = 1;
784 $arr['type'] = 'wall';
785 $arr['gravity'] = 0;
786 $arr['origin'] = 1;
787 $arr['author-name'] = $arr['owner-name'] = $self[0]['name'];
788 $arr['author-link'] = $arr['owner-link'] = $self[0]['url'];
789 $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
790
791 $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]';
792 $APhoto = '[url=' . $self[0]['url'] . ']' . '[img]' . $self[0]['thumb'] . '[/img][/url]';
793
794 $B = '[url=' . $combined['url'] . ']' . $combined['name'] . '[/url]';
795 $BPhoto = '[url=' . $combined['url'] . ']' . '[img]' . $combined['thumb'] . '[/img][/url]';
796
797 $arr['verb'] = ACTIVITY_JOIN;
798 $arr['object-type'] = ACTIVITY_OBJ_GROUP;
799 $arr['body'] = sprintf( t('%1$s has joined %2$s'), $A, $B)."\n\n\n" .$BPhoto;
800 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_GROUP . '</type><title>' . $combined['name'] . '</title>'
801 . '<id>' . $combined['url'] . '/' . $combined['name'] . '</id>';
802 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $combined['url'] . '" />' . "\n");
803 $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $combined['thumb'] . '" />' . "\n");
804 $arr['object'] .= '</link></object>' . "\n";
805
806 $arr['last-child'] = 1;
807
808 $arr['allow_cid'] = $user[0]['allow_cid'];
809 $arr['allow_gid'] = $user[0]['allow_gid'];
810 $arr['deny_cid'] = $user[0]['deny_cid'];
811 $arr['deny_gid'] = $user[0]['deny_gid'];
812
813 $i = item_store($arr);
814 if($i)
815 proc_run('php',"include/notifier.php","activity","$i");
816
817 }
818 }
819 }
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
820 xml_status(0); // Success
821 return; // NOTREACHED
822
823 ////////////////////// End of this scenario ///////////////////////////////////////////////
824 }
825
826 // somebody arrived here by mistake or they are fishing. Send them to the homepage.
827
2637831 friendica some more zot changes migrating back to f9a mainline
friendika authored
828 goaway(z_root());
524f73e projectred A bit more telemetry of friend confirms and lots of extra doco
projectred authored
829 // NOTREACHED
830
6348e70 projectred Initial checkin
projectred authored
831 }
Something went wrong with that request. Please try again.