3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2009-2010, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * @package OStatusPlugin
22 * @maintainer Brion Vibber <brion@status.net>
25 class Ostatus_profile extends Memcached_DataObject
27 public $__table = 'ostatus_profile';
40 public /*static*/ function staticGet($k, $v=null)
42 return parent::staticGet(__CLASS__, $k, $v);
46 * return table definition for DB_DataObject
48 * DB_DataObject needs to know something about the table to manipulate
49 * instances. This method provides all the DB_DataObject needs to know.
51 * @return array array of column definitions
56 return array('uri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
57 'profile_id' => DB_DATAOBJECT_INT,
58 'group_id' => DB_DATAOBJECT_INT,
59 'feeduri' => DB_DATAOBJECT_STR,
60 'salmonuri' => DB_DATAOBJECT_STR,
61 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
62 'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
65 static function schemaDef()
67 return array(new ColumnDef('uri', 'varchar',
69 new ColumnDef('profile_id', 'integer',
71 new ColumnDef('group_id', 'integer',
73 new ColumnDef('feeduri', 'varchar',
75 new ColumnDef('salmonuri', 'text',
77 new ColumnDef('created', 'datetime',
79 new ColumnDef('modified', 'datetime',
84 * return key definitions for DB_DataObject
86 * DB_DataObject needs to know about keys that the table has; this function
89 * @return array key definitions
94 return array_keys($this->keyTypes());
98 * return key definitions for Memcached_DataObject
100 * Our caching system uses the same key definitions, but uses a different
101 * method to get them.
103 * @return array key definitions
108 return array('uri' => 'K', 'profile_id' => 'U', 'group_id' => 'U', 'feeduri' => 'U');
111 function sequenceKey()
113 return array(false, false, false);
117 * Fetch the StatusNet-side profile for this feed
120 public function localProfile()
122 if ($this->profile_id) {
123 return Profile::staticGet('id', $this->profile_id);
129 * Fetch the StatusNet-side profile for this feed
132 public function localGroup()
134 if ($this->group_id) {
135 return User_group::staticGet('id', $this->group_id);
141 * Returns an XML string fragment with profile information as an
142 * Activity Streams noun object with the given element type.
144 * Assumes that 'activity' namespace has been previously defined.
146 * @param string $element one of 'actor', 'subject', 'object', 'target'
149 function asActivityNoun($element)
151 $xs = new XMLStringer(true);
152 $avatarHref = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
153 $avatarType = 'image/png';
154 if ($this->isGroup()) {
155 $type = 'http://activitystrea.ms/schema/1.0/group';
156 $self = $this->localGroup();
158 // @fixme put a standard getAvatar() interface on groups too
159 if ($self->homepage_logo) {
160 $avatarHref = $self->homepage_logo;
161 $map = array('png' => 'image/png',
162 'jpg' => 'image/jpeg',
163 'jpeg' => 'image/jpeg',
164 'gif' => 'image/gif');
165 $extension = pathinfo(parse_url($avatarHref, PHP_URL_PATH), PATHINFO_EXTENSION);
166 if (isset($map[$extension])) {
167 $avatarType = $map[$extension];
171 $type = 'http://activitystrea.ms/schema/1.0/person';
172 $self = $this->localProfile();
173 $avatar = $self->getAvatar(AVATAR_PROFILE_SIZE);
175 $avatarHref = $avatar->url;
176 $avatarType = $avatar->mediatype;
179 $xs->elementStart('activity:' . $element);
181 'activity:object-type',
189 $xs->element('title', null, $self->getBestName());
193 'type' => $avatarType,
194 'href' => $avatarHref
199 $xs->elementEnd('activity:' . $element);
201 return $xs->getString();
209 return (strpos($this->feeduri, '/groups/') !== false);
213 * Subscribe a local user to this remote user.
214 * PuSH subscription will be started if necessary, and we'll
215 * send a Salmon notification to the remote server if available
216 * notifying them of the sub.
219 * @return boolean success
220 * @throws FeedException
222 public function subscribeLocalToRemote(User $user)
224 if ($this->isGroup()) {
225 throw new ServerException("Can't subscribe to a remote group");
228 if ($this->subscribe()) {
229 if ($user->subscribeTo($this->localProfile())) {
230 $this->notify($user->getProfile(), ActivityVerb::FOLLOW, $this);
238 * Mark this remote profile as subscribing to the given local user,
239 * and send appropriate notifications to the user.
241 * This will generally be in response to a subscription notification
242 * from a foreign site to our local Salmon response channel.
245 * @return boolean success
247 public function subscribeRemoteToLocal(User $user)
249 if ($this->isGroup()) {
250 throw new ServerException("Remote groups can't subscribe to local users");
253 // @fixme use regular channels for subbing, once they accept remote profiles
254 $sub = new Subscription();
255 $sub->subscriber = $this->profile_id;
256 $sub->subscribed = $user->id;
257 $sub->created = common_sql_now(); // current time
259 if ($sub->insert()) {
260 // @fixme use subs_notify() if refactored to take profiles?
261 mail_subscribe_notify_profile($user, $this->localProfile());
268 * Send a subscription request to the hub for this feed.
269 * The hub will later send us a confirmation POST to /main/push/callback.
271 * @return bool true on success, false on failure
272 * @throws ServerException if feed state is not valid
274 public function subscribe()
276 $feedsub = FeedSub::ensureFeed($this->feeduri);
277 if ($feedsub->sub_state == 'active' || $feedsub->sub_state == 'subscribe') {
279 } else if ($feedsub->sub_state == '' || $feedsub->sub_state == 'inactive') {
280 return $feedsub->subscribe();
281 } else if ('unsubscribe') {
282 throw new FeedSubException("Unsub is pending, can't subscribe...");
287 * Send a PuSH unsubscription request to the hub for this feed.
288 * The hub will later send us a confirmation POST to /main/push/callback.
290 * @return bool true on success, false on failure
291 * @throws ServerException if feed state is not valid
293 public function unsubscribe() {
294 $feedsub = FeedSub::staticGet('uri', $this->feeduri);
295 if ($feedsub->sub_state == 'active') {
296 return $feedsub->unsubscribe();
297 } else if ($feedsub->sub_state == '' || $feedsub->sub_state == 'inactive' || $feedsub->sub_state == 'unsubscribe') {
299 } else if ($feedsub->sub_state == 'subscribe') {
300 throw new FeedSubException("Feed is awaiting subscription, can't unsub...");
305 * Send an Activity Streams notification to the remote Salmon endpoint,
308 * @param Profile $actor Actor who did the activity
309 * @param string $verb Activity::SUBSCRIBE or Activity::JOIN
310 * @param Object $object object of the action; must define asActivityNoun($tag)
312 public function notify($actor, $verb, $object=null)
314 if (!($actor instanceof Profile)) {
315 $type = gettype($actor);
316 if ($type == 'object') {
317 $type = get_class($actor);
319 throw new ServerException("Invalid actor passed to " . __METHOD__ . ": " . $type);
321 if ($object == null) {
324 if ($this->salmonuri) {
327 $id = TagURI::mint('%s:%s:%s',
330 common_date_iso8601(time()));
332 // @fixme consolidate all these NS settings somewhere
333 $attributes = array('xmlns' => Activity::ATOM,
334 'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
335 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
336 'xmlns:georss' => 'http://www.georss.org/georss',
337 'xmlns:ostatus' => 'http://ostatus.org/schema/1.0');
339 $entry = new XMLStringer();
340 $entry->elementStart('entry', $attributes);
341 $entry->element('id', null, $id);
342 $entry->element('title', null, $text);
343 $entry->element('summary', null, $text);
344 $entry->element('published', null, common_date_w3dtf(common_sql_now()));
346 $entry->element('activity:verb', null, $verb);
347 $entry->raw($actor->asAtomAuthor());
348 $entry->raw($actor->asActivityActor());
349 $entry->raw($object->asActivityNoun('object'));
350 $entry->elementEnd('entry');
352 $xml = $entry->getString();
353 common_log(LOG_INFO, "Posting to Salmon endpoint $this->salmonuri: $xml");
355 $salmon = new Salmon(); // ?
356 $salmon->post($this->salmonuri, $xml);
360 public function notifyActivity($activity)
362 if ($this->salmonuri) {
364 $xml = $activity->asString(true);
366 $salmon = new Salmon(); // ?
368 $salmon->post($this->salmonuri, $xml);
374 function getBestName()
376 if ($this->isGroup()) {
377 return $this->localGroup()->getBestName();
379 return $this->localProfile()->getBestName();
383 function atomFeed($actor)
385 $feed = new Atom10Feed();
386 // @fixme should these be set up somewhere else?
387 $feed->addNamespace('activity', 'http://activitystrea.ms/spec/1.0/');
388 $feed->addNamespace('thr', 'http://purl.org/syndication/thread/1.0');
389 $feed->addNamespace('georss', 'http://www.georss.org/georss');
390 $feed->addNamespace('ostatus', 'http://ostatus.org/schema/1.0');
392 $taguribase = common_config('integration', 'taguri');
393 $feed->setId("tag:{$taguribase}:UserTimeline:{$actor->id}"); // ???
395 $feed->setTitle($actor->getBestName() . ' timeline'); // @fixme
396 $feed->setUpdated(time());
397 $feed->setPublished(time());
399 $feed->addLink(common_local_url('ApiTimelineUser',
400 array('id' => $actor->id,
402 array('rel' => 'self',
403 'type' => 'application/atom+xml'));
405 $feed->addLink(common_local_url('userbyid',
406 array('id' => $actor->id)),
407 array('rel' => 'alternate',
408 'type' => 'text/html'));
414 * Read and post notices for updates from the feed.
415 * Currently assumes that all items in the feed are new,
416 * coming from a PuSH hub.
418 * @param DOMDocument $feed
420 public function processFeed($feed)
422 $entries = $feed->getElementsByTagNameNS(Activity::ATOM, 'entry');
423 if ($entries->length == 0) {
424 common_log(LOG_ERR, __METHOD__ . ": no entries in feed update, ignoring");
428 for ($i = 0; $i < $entries->length; $i++) {
429 $entry = $entries->item($i);
430 $this->processEntry($entry, $feed);
435 * Process a posted entry from this feed source.
437 * @param DOMElement $entry
438 * @param DOMElement $feed for context
440 protected function processEntry($entry, $feed)
442 $activity = new Activity($entry, $feed);
444 $debug = var_export($activity, true);
445 common_log(LOG_DEBUG, $debug);
447 if ($activity->verb == ActivityVerb::POST) {
448 $this->processPost($activity);
450 common_log(LOG_INFO, "Ignoring activity with unrecognized verb $activity->verb");
455 * Process an incoming post activity from this remote feed.
456 * @param Activity $activity
458 protected function processPost($activity)
460 if ($this->isGroup()) {
461 // @fixme validate these profiles in some way!
462 $oprofile = self::ensureActorProfile($activity);
464 $actorUri = self::getActorProfileURI($activity);
465 if ($actorUri == $this->uri) {
466 // @fixme check if profile info has changed and update it
468 // @fixme drop or reject the messages once we've got the canonical profile URI recorded sanely
469 common_log(LOG_INFO, "OStatus: Warning: non-group post with unexpected author: $actorUri expected $this->uri");
475 $sourceUri = $activity->object->id;
477 $dupe = Notice::staticGet('uri', $sourceUri);
480 common_log(LOG_INFO, "OStatus: ignoring duplicate post: $sourceUri");
486 if ($activity->object->link) {
487 $sourceUrl = $activity->object->link;
488 } else if (preg_match('!^https?://!', $activity->object->id)) {
489 $sourceUrl = $activity->object->id;
492 // @fixme sanitize and save HTML content if available
494 $content = $activity->object->title;
496 $params = array('is_local' => Notice::REMOTE_OMB,
498 'uri' => $sourceUri);
500 $location = $activity->context->location;
503 $params['lat'] = $location->lat;
504 $params['lon'] = $location->lon;
505 if ($location->location_id) {
506 $params['location_ns'] = $location->location_ns;
507 $params['location_id'] = $location->location_id;
511 // @fixme ensure that groups get handled correctly
513 $saved = Notice::saveNew($oprofile->localProfile()->id,
518 // Record which feed this came through...
519 Ostatus_source::saveNew($saved, $this, 'push');
523 * @param string $profile_url
524 * @return Ostatus_profile
525 * @throws FeedSubException
527 public static function ensureProfile($profile_uri, $hints=array())
529 // Get the canonical feed URI and check it
530 $discover = new FeedDiscovery();
531 $feeduri = $discover->discoverFromURL($profile_uri);
533 //$feedsub = FeedSub::ensureFeed($feeduri, $discover->feed);
534 $huburi = $discover->getAtomLink('hub');
535 $salmonuri = $discover->getAtomLink('salmon');
538 // We can only deal with folks with a PuSH hub
539 throw new FeedSubNoHubException();
542 // Try to get a profile from the feed activity:subject
544 $feedEl = $discover->feed->documentElement;
546 $subject = ActivityUtils::child($feedEl, Activity::SUBJECT, Activity::SPEC);
548 if (!empty($subject)) {
549 $subjObject = new ActivityObject($subject);
550 return self::ensureActivityObjectProfile($subjObject, $feeduri, $salmonuri, $hints);
553 // Otherwise, try the feed author
555 $author = ActivityUtils::child($feedEl, Activity::AUTHOR, Activity::ATOM);
557 if (!empty($author)) {
558 $authorObject = new ActivityObject($author);
559 return self::ensureActivityObjectProfile($authorObject, $feeduri, $salmonuri, $hints);
562 // Sheesh. Not a very nice feed! Let's try fingerpoken in the
565 $entries = $discover->feed->getElementsByTagNameNS(Activity::ATOM, 'entry');
567 if (!empty($entries) && $entries->length > 0) {
569 $entry = $entries->item(0);
571 $actor = ActivityUtils::child($entry, Activity::ACTOR, Activity::SPEC);
573 if (!empty($actor)) {
574 $actorObject = new ActivityObject($actor);
575 return self::ensureActivityObjectProfile($actorObject, $feeduri, $salmonuri, $hints);
579 $author = ActivityUtils::child($entry, Activity::AUTHOR, Activity::ATOM);
581 if (!empty($author)) {
582 $authorObject = new ActivityObject($author);
583 return self::ensureActivityObjectProfile($authorObject, $feeduri, $salmonuri, $hints);
587 // XXX: make some educated guesses here
589 throw new FeedSubException("Can't find enough profile information to make a feed.");
594 * Download and update given avatar image
596 * @throws Exception in various failure cases
598 protected function updateAvatar($url)
600 // @fixme this should be better encapsulated
601 // ripped from oauthstore.php (for old OMB client)
602 $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
603 copy($url, $temp_filename);
605 if ($this->isGroup()) {
606 $id = $this->group_id;
608 $id = $this->profile_id;
610 // @fixme should we be using different ids?
611 $imagefile = new ImageFile($id, $temp_filename);
612 $filename = Avatar::filename($id,
613 image_type_to_extension($imagefile->type),
616 rename($temp_filename, Avatar::path($filename));
617 if ($this->isGroup()) {
618 $group = $this->localGroup();
619 $group->setOriginal($filename);
621 $profile = $this->localProfile();
622 $profile->setOriginal($filename);
626 protected static function getActivityObjectAvatar($object)
628 // XXX: go poke around in the feed
629 return $object->avatar;
633 * Get an appropriate avatar image source URL, if available.
635 * @param ActivityObject $actor
636 * @param DOMElement $feed
640 protected static function getAvatar($actor, $feed)
644 if ($actor->avatar) {
645 $url = trim($actor->avatar);
648 // Check <atom:logo> and <atom:icon> on the feed
649 $els = $feed->childNodes();
650 if ($els && $els->length) {
651 for ($i = 0; $i < $els->length; $i++) {
652 $el = $els->item($i);
653 if ($el->namespaceURI == Activity::ATOM) {
654 if (empty($url) && $el->localName == 'logo') {
655 $url = trim($el->textContent);
658 if (empty($icon) && $el->localName == 'icon') {
660 $icon = trim($el->textContent);
665 if ($icon && !$url) {
670 $opts = array('allowed_schemes' => array('http', 'https'));
671 if (Validate::uri($url, $opts)) {
675 return common_path('plugins/OStatus/images/96px-Feed-icon.svg.png');
679 * Fetch, or build if necessary, an Ostatus_profile for the actor
680 * in a given Activity Streams activity.
682 * @param Activity $activity
683 * @param string $feeduri if we already know the canonical feed URI!
684 * @param string $salmonuri if we already know the salmon return channel URI
685 * @return Ostatus_profile
688 public static function ensureActorProfile($activity, $feeduri=null, $salmonuri=null)
690 return self::ensureActivityObjectProfile($activity->actor, $feeduri, $salmonuri);
693 public static function ensureActivityObjectProfile($object, $feeduri=null, $salmonuri=null, $hints=array())
695 $profile = self::getActivityObjectProfile($object);
697 $profile = self::createActivityObjectProfile($object, $feeduri, $salmonuri, $hints);
703 * @param Activity $activity
704 * @return mixed matching Ostatus_profile or false if none known
706 protected static function getActorProfile($activity)
708 return self::getActivityObjectProfile($activity->actor);
711 protected static function getActivityObjectProfile($object)
713 $uri = self::getActivityObjectProfileURI($object);
714 return Ostatus_profile::staticGet('uri', $uri);
717 protected static function getActorProfileURI($activity)
719 return self::getActivityObjectProfileURI($activity->actor);
723 * @param Activity $activity
725 * @throws ServerException
727 protected static function getActivityObjectProfileURI($object)
729 $opts = array('allowed_schemes' => array('http', 'https'));
730 if ($object->id && Validate::uri($object->id, $opts)) {
733 if ($object->link && Validate::uri($object->link, $opts)) {
734 return $object->link;
736 throw new ServerException("No author ID URI found");
740 * @fixme validate stuff somewhere
743 protected static function createActorProfile($activity, $feeduri=null, $salmonuri=null)
745 $actor = $activity->actor;
747 self::createActivityObjectProfile($actor, $feeduri, $salmonuri);
750 protected static function createActivityObjectProfile($object, $feeduri=null, $salmonuri=null, $hints=array())
752 $homeuri = $object->id;
753 $nickname = self::getActivityObjectNickname($object, $hints);
754 $avatar = self::getActivityObjectAvatar($object);
757 common_log(LOG_DEBUG, __METHOD__ . " empty actor profile URI: " . var_export($activity, true));
758 throw new ServerException("No profile URI");
761 if (empty($feeduri)) {
762 if (array_key_exists('feedurl', $hints)) {
763 $feeduri = $hints['feedurl'];
767 if (empty($salmonuri)) {
768 if (array_key_exists('salmon', $hints)) {
769 $salmonuri = $hints['salmon'];
773 if (!$feeduri || !$salmonuri) {
774 // Get the canonical feed URI and check it
775 $discover = new FeedDiscovery();
776 $feeduri = $discover->discoverFromURL($homeuri);
778 $huburi = $discover->getAtomLink('hub');
779 $salmonuri = $discover->getAtomLink('salmon');
782 // We can only deal with folks with a PuSH hub
783 throw new FeedSubNoHubException();
787 $profile = new Profile();
788 $profile->nickname = $nickname;
789 $profile->fullname = $object->title;
790 if (!empty($object->link)) {
791 $profile->profileurl = $object->link;
792 } else if (array_key_exists('profileurl', $hints)) {
793 $profile->profileurl = $hints['profileurl'];
795 $profile->created = common_sql_now();
798 // @fixme tags/categories
800 // @todo tags from categories
801 // @todo lat/lon/location?
803 $profile_id = $profile->insert();
806 throw new ServerException("Can't save local profile");
809 // @fixme either need to do feed discovery here
810 // or need to split out some of the feed stuff
811 // so we can leave it empty until later.
813 $oprofile = new Ostatus_profile();
815 $oprofile->uri = $homeuri;
816 $oprofile->feeduri = $feeduri;
817 $oprofile->salmonuri = $salmonuri;
818 $oprofile->profile_id = $profile_id;
820 $oprofile->created = common_sql_now();
821 $oprofile->modified = common_sql_now();
823 $ok = $oprofile->insert();
826 $oprofile->updateAvatar($avatar);
829 throw new ServerException("Can't save OStatus profile");
833 protected static function getActivityObjectNickname($object, $hints=array())
835 if (!empty($object->nickname)) {
836 return common_nicknamize($object->nickname);
839 // Try the definitive ID
841 $nickname = self::nicknameFromURI($object->id);
843 // Try a Webfinger if one was passed (way) down
845 if (empty($nickname)) {
846 if (array_key_exists('webfinger', $hints)) {
847 $nickname = self::nicknameFromURI($hints['webfinger']);
853 if (empty($nickname)) {
854 $nickname = common_nicknamize($object->title);
860 protected static function nicknameFromURI($uri)
862 preg_match('/(\w+):/', $uri, $matches);
864 $protocol = $matches[1];
869 if (preg_match("/^$protocol:(.*)?@.*\$/", $uri, $matches)) {
870 return common_canonical_nickname($matches[1]);
874 return common_url_to_nickname($uri);
881 public static function ensureWebfinger($addr)
885 $oprofile = Ostatus_profile::staticGet('uri', 'acct:'.$addr);
887 if (!empty($oprofile)) {
891 // Now, try some discovery
893 $wf = new Webfinger();
895 $result = $wf->lookup($addr);
901 foreach ($result->links as $link) {
902 switch ($link['rel']) {
903 case Webfinger::PROFILEPAGE:
904 $profileUrl = $link['href'];
907 $salmonEndpoint = $link['href'];
909 case Webfinger::UPDATESFROM:
910 $feedUrl = $link['href'];
913 common_log(LOG_NOTICE, "Don't know what to do with rel = '{$link['rel']}'");
918 $hints = array('webfinger' => $addr,
919 'profileurl' => $profileUrl,
920 'feedurl' => $feedUrl,
921 'salmon' => $salmonEndpoint);
923 // If we got a feed URL, try that
925 if (isset($feedUrl)) {
927 $oprofile = self::ensureProfile($feedUrl, $hints);
929 } catch (Exception $e) {
930 common_log(LOG_WARNING, "Failed creating profile from feed URL '$feedUrl': " . $e->getMessage());
935 // If we got a profile page, try that!
937 if (isset($profileUrl)) {
939 $oprofile = self::ensureProfile($profileUrl, $hints);
941 } catch (Exception $e) {
942 common_log(LOG_WARNING, "Failed creating profile from profile URL '$profileUrl': " . $e->getMessage());
950 if (isset($salmonEndpoint)) {
952 // An account URL, a salmon endpoint, and a dream? Not much to go
953 // on, but let's give it a try
955 $uri = 'acct:'.$addr;
957 $profile = new Profile();
959 $profile->nickname = self::nicknameFromUri($uri);
960 $profile->created = common_sql_now();
962 if (isset($profileUrl)) {
963 $profile->profileurl = $profileUrl;
966 $profile_id = $profile->insert();
969 common_log_db_error($profile, 'INSERT', __FILE__);
970 throw new Exception("Couldn't save profile for '$addr'");
973 $oprofile = new Ostatus_profile();
975 $oprofile->uri = $uri;
976 $oprofile->salmonuri = $salmonEndpoint;
977 $oprofile->profile_id = $profile_id;
978 $oprofile->created = common_sql_now();
980 if (isset($feedUrl)) {
981 $profile->feeduri = $feedUrl;
984 $result = $oprofile->insert();
987 common_log_db_error($oprofile, 'INSERT', __FILE__);
988 throw new Exception("Couldn't save ostatus_profile for '$addr'");