3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 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/>.
20 if (!defined('STATUSNET')) {
25 * @package OStatusPlugin
26 * @maintainer Brion Vibber <brion@status.net>
28 class Ostatus_source extends Managed_DataObject
30 public $__table = 'ostatus_source';
32 public $notice_id; // notice we're referring to
33 public $profile_uri; // uri of the ostatus_profile this came through -- may be a group feed
34 public $method; // push or salmon
38 public static function schemaDef()
42 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'Notice ID relation'),
43 'profile_uri' => array('type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'Profile URI'),
44 'method' => array('type' => 'enum("push","salmon")', 'not null' => true, 'description' => 'source method'),
45 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
46 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
48 'primary key' => array('notice_id'),
49 'foreign keys' => array(
50 'ostatus_source_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
51 // not in profile table yet 'ostatus_source_profile_uri_fkey' => array('profile', array('profile_uri' => 'uri')),
54 'ostatus_source_profile_uri_idx' => array('profile_uri'),
60 * Save a remote notice source record; this helps indicate how trusted we are.
61 * @param string $method
63 public static function saveNew(Notice $notice, Ostatus_profile $oprofile, $method)
65 $osource = new Ostatus_source();
66 $osource->notice_id = $notice->id;
67 $osource->profile_uri = $oprofile->uri;
68 $osource->method = $method;
69 $osource->created = common_sql_now();
70 if ($osource->insert()) {
73 common_log_db_error($osource, 'INSERT', __FILE__);