forked from GNUsocial/gnu-social
		
	Add a registration activity to the end of every backup
This commit is contained in:
		@@ -1180,4 +1180,34 @@ class User extends Managed_DataObject
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    function registrationActivity()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $profile = $this->getProfile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $service = new ActivityObject();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $service->type = "service";
 | 
				
			||||||
 | 
					        $service->displayName = common_config('site', 'name');
 | 
				
			||||||
 | 
					        $service->url = common_root_url();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $act = new Activity();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $act->actor = ActivityObject::fromProfile($profile);
 | 
				
			||||||
 | 
					        $act->verb = ActivityVerb::JOIN;
 | 
				
			||||||
 | 
					        $act->objects[] = $service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $act->id = TagURI::mint('user:register:%d',
 | 
				
			||||||
 | 
					                                $this->id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $act->time = strtotime($this->created);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $act->title = _("Register");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $act->content = sprintf(_('%1$s joined %2$s.'),
 | 
				
			||||||
 | 
					                               $profile->getBestName(),
 | 
				
			||||||
 | 
					                               $service->displayName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $act;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -132,6 +132,25 @@ class UserActivityStream extends AtomUserNoticeFeed
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // We always add the registration activity at the end, even if
 | 
				
			||||||
 | 
					        // they have older activities (from restored backups) in their stream.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            $ract = $this->user->registrationActivity();
 | 
				
			||||||
 | 
					            if ($format == Feed::ATOM) {
 | 
				
			||||||
 | 
					                $ract->outputTo($this, false, false);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                if ($haveOne) {
 | 
				
			||||||
 | 
					                    fwrite($handle, ",");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                fwrite($handle, json_encode($ract->asArray()));
 | 
				
			||||||
 | 
					                $haveOne = true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (Exception $e) {
 | 
				
			||||||
 | 
					            common_log(LOG_ERR, $e->getMessage());
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function compareObject($a, $b)
 | 
					    function compareObject($a, $b)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user