]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
OStatus: fix up Salmon endpoint detection/saving, timestamp fixes.
authorBrion Vibber <brion@pobox.com>
Fri, 19 Feb 2010 18:29:06 +0000 (10:29 -0800)
committerBrion Vibber <brion@pobox.com>
Fri, 19 Feb 2010 18:29:06 +0000 (10:29 -0800)
plugins/OStatus/actions/salmon.php
plugins/OStatus/classes/FeedSub.php
plugins/OStatus/classes/Ostatus_profile.php

index e9d6015f43bf13f5656231d6b0852a550a914cc5..2da9db9eb74beca203fcb1d6be87ffeda54bf36e 100644 (file)
@@ -142,7 +142,7 @@ class SalmonAction extends Action
     function ensureProfile()
     {
         $actor = $this->act->actor;
-
+        common_log(LOG_DEBUG, "Received salmon bit: " . var_export($this->act, true));
         if (empty($actor->id)) {
             throw new Exception("Received a salmon slap from unidentified actor.");
         }
index dc2c0b710bc128b2c0b406678693af8d3d0bca0d..bf9d063fa111ed6b7091d09e94b48606a6e818a5 100644 (file)
@@ -99,7 +99,7 @@ class FeedSub extends Memcached_DataObject
                      'sub_state' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
                      'sub_start' => 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,
                      'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
     }
index e0cb467e5e3228b29b9dc3f2f51eabf0909e5abc..319b76a661c5802b09d3c0c91d7d5894912abee5 100644 (file)
@@ -328,7 +328,7 @@ class Ostatus_profile extends Memcached_DataObject
             $entry->element('id', null, $id);
             $entry->element('title', 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->raw($actor->asAtomAuthor());
@@ -516,7 +516,7 @@ class Ostatus_profile extends Memcached_DataObject
             throw new FeedSubException('empty 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 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
      */
-    public static function ensureActorProfile($activity, $feeduri=null)
+    public static function ensureActorProfile($activity, $feeduri=null, $salmonuri=null)
     {
         $profile = self::getActorProfile($activity);
         if (!$profile) {
-            $profile = self::createActorProfile($activity, $feeduri);
+            $profile = self::createActorProfile($activity, $feeduri, $salmonuri);
         }
         return $profile;
     }
@@ -640,7 +641,7 @@ class Ostatus_profile extends Memcached_DataObject
     /**
      * @fixme validate stuff somewhere
      */
-    protected static function createActorProfile($activity, $feeduri=null)
+    protected static function createActorProfile($activity, $feeduri=null, $salmonuri=null)
     {
         $actor = $activity->actor;
         $homeuri = self::getActorProfileURI($activity);
@@ -674,10 +675,17 @@ class Ostatus_profile extends Memcached_DataObject
         $oprofile = new Ostatus_profile();
         $oprofile->uri = $homeuri;
         if ($feeduri) {
+            // If we don't have these, we can look them up later.
             $oprofile->feeduri = $feeduri;
+            if ($salmonuri) {
+                $oprofile->salmonuri = $salmonuri;
+            }
         }
         $oprofile->profile_id = $profile->id;
 
+        $oprofile->created = common_sql_now();
+        $oprofile->modified = common_sql_now();
+
         $ok = $oprofile->insert();
         if ($ok) {
             $oprofile->updateAvatar($avatar);