| 
									
										
										
										
											2013-10-20 15:32:56 +02:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * WebFinger resource for Notice objects | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package   GNUsocial | 
					
						
							|  |  |  |  * @author    Mikael Nordfeldth | 
					
						
							|  |  |  |  * @copyright 2013 Free Software Foundation, Inc. | 
					
						
							|  |  |  |  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 | 
					
						
							|  |  |  |  * @link      http://status.net/ | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class WebFingerResource_Notice extends WebFingerResource | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     public function __construct(Notice $object) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // The type argument above verifies that it's our class
 | 
					
						
							|  |  |  |         parent::__construct($object); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function updateXRD(XML_XRD $xrd) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2013-11-01 16:54:59 +01:00
										 |  |  |         if (Event::handle('StartWebFingerNoticeLinks', array($xrd, $this->object))) { | 
					
						
							| 
									
										
										
										
											2016-03-27 14:56:27 +02:00
										 |  |  |             if ($this->object->isLocal()) { | 
					
						
							|  |  |  |                 $xrd->links[] = new XML_XRD_Element_Link('alternate', | 
					
						
							| 
									
										
										
										
											2013-11-01 16:54:59 +01:00
										 |  |  |                                     common_local_url('ApiStatusesShow', | 
					
						
							|  |  |  |                                         array('id'=>$this->object->id, | 
					
						
							|  |  |  |                                               'format'=>'atom')), | 
					
						
							|  |  |  |                                     'application/atom+xml'); | 
					
						
							| 
									
										
										
										
											2013-10-20 15:32:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-27 14:56:27 +02:00
										 |  |  |                 $xrd->links[] = new XML_XRD_Element_Link('alternate', | 
					
						
							| 
									
										
										
										
											2013-11-01 16:54:59 +01:00
										 |  |  |                                     common_local_url('ApiStatusesShow', | 
					
						
							|  |  |  |                                         array('id'=>$this->object->id, | 
					
						
							|  |  |  |                                               'format'=>'json')), | 
					
						
							|  |  |  |                                     'application/json'); | 
					
						
							| 
									
										
										
										
											2016-03-27 14:56:27 +02:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 try { | 
					
						
							|  |  |  |                     $xrd->links[] = new XML_XRD_Element_Link('alternate', | 
					
						
							|  |  |  |                                         $this->object->getUrl(), | 
					
						
							|  |  |  |                                         'text/html'); | 
					
						
							|  |  |  |                 } catch (InvalidUrlException $e) { | 
					
						
							|  |  |  |                     // don't do a fallback in webfinger
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2013-11-01 16:54:59 +01:00
										 |  |  |             Event::handle('EndWebFingerNoticeLinks', array($xrd, $this->object)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-10-20 15:32:56 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } |