OStatus: fix up Salmon endpoint detection/saving, timestamp fixes.

This commit is contained in:
Brion Vibber 2010-02-19 10:29:06 -08:00
parent 2c09702b2d
commit 114eb310ca
3 changed files with 15 additions and 7 deletions

View File

@ -142,7 +142,7 @@ class SalmonAction extends Action
function ensureProfile() function ensureProfile()
{ {
$actor = $this->act->actor; $actor = $this->act->actor;
common_log(LOG_DEBUG, "Received salmon bit: " . var_export($this->act, true));
if (empty($actor->id)) { if (empty($actor->id)) {
throw new Exception("Received a salmon slap from unidentified actor."); throw new Exception("Received a salmon slap from unidentified actor.");
} }

View File

@ -99,7 +99,7 @@ class FeedSub extends Memcached_DataObject
'sub_state' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL, 'sub_state' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'sub_start' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME, 'sub_start' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
'sub_end' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME, 'sub_end' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
'last_update' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL, 'last_update' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL, 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL); 'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
} }

View File

@ -328,7 +328,7 @@ class Ostatus_profile extends Memcached_DataObject
$entry->element('id', null, $id); $entry->element('id', null, $id);
$entry->element('title', null, $text); $entry->element('title', null, $text);
$entry->element('summary', null, $text); $entry->element('summary', null, $text);
$entry->element('published', null, common_date_w3dtf(time())); $entry->element('published', null, common_date_w3dtf(common_sql_now()));
$entry->element('activity:verb', null, $verb); $entry->element('activity:verb', null, $verb);
$entry->raw($actor->asAtomAuthor()); $entry->raw($actor->asAtomAuthor());
@ -516,7 +516,7 @@ class Ostatus_profile extends Memcached_DataObject
throw new FeedSubException('empty feed'); throw new FeedSubException('empty feed');
} }
$first = new Activity($entries->item(0), $discover->feed); $first = new Activity($entries->item(0), $discover->feed);
return self::ensureActorProfile($first, $feeduri); return self::ensureActorProfile($first, $feeduri, $salmonuri);
} }
/** /**
@ -598,13 +598,14 @@ class Ostatus_profile extends Memcached_DataObject
* *
* @param Activity $activity * @param Activity $activity
* @param string $feeduri if we already know the canonical feed URI! * @param string $feeduri if we already know the canonical feed URI!
* @param string $salmonuri if we already know the salmon return channel URI
* @return Ostatus_profile * @return Ostatus_profile
*/ */
public static function ensureActorProfile($activity, $feeduri=null) public static function ensureActorProfile($activity, $feeduri=null, $salmonuri=null)
{ {
$profile = self::getActorProfile($activity); $profile = self::getActorProfile($activity);
if (!$profile) { if (!$profile) {
$profile = self::createActorProfile($activity, $feeduri); $profile = self::createActorProfile($activity, $feeduri, $salmonuri);
} }
return $profile; return $profile;
} }
@ -640,7 +641,7 @@ class Ostatus_profile extends Memcached_DataObject
/** /**
* @fixme validate stuff somewhere * @fixme validate stuff somewhere
*/ */
protected static function createActorProfile($activity, $feeduri=null) protected static function createActorProfile($activity, $feeduri=null, $salmonuri=null)
{ {
$actor = $activity->actor; $actor = $activity->actor;
$homeuri = self::getActorProfileURI($activity); $homeuri = self::getActorProfileURI($activity);
@ -674,10 +675,17 @@ class Ostatus_profile extends Memcached_DataObject
$oprofile = new Ostatus_profile(); $oprofile = new Ostatus_profile();
$oprofile->uri = $homeuri; $oprofile->uri = $homeuri;
if ($feeduri) { if ($feeduri) {
// If we don't have these, we can look them up later.
$oprofile->feeduri = $feeduri; $oprofile->feeduri = $feeduri;
if ($salmonuri) {
$oprofile->salmonuri = $salmonuri;
}
} }
$oprofile->profile_id = $profile->id; $oprofile->profile_id = $profile->id;
$oprofile->created = common_sql_now();
$oprofile->modified = common_sql_now();
$ok = $oprofile->insert(); $ok = $oprofile->insert();
if ($ok) { if ($ok) {
$oprofile->updateAvatar($avatar); $oprofile->updateAvatar($avatar);