return Notice::getKV('id', $n2s->notice_id);
}
+ $dupe = Notice::getKV('uri', $statusUri);
+ if($dupe instanceof Notice) {
+ // Add it to our record
+ Notice_to_status::saveNew($dupe->id, $statusId);
+ common_log(
+ LOG_INFO,
+ __METHOD__ . " - Ignoring duplicate import: {$statusId}"
+ );
+ return $dupe;
+ }
+
// If it's a retweet, save it as a repeat!
if (!empty($status->retweeted_status)) {
common_log(LOG_INFO, "Status {$statusId} is a retweet of " . twitter_id($status->retweeted_status) . ".");
$notice->profile_id = $profile->id;
$notice->uri = $statusUri;
$notice->url = $statusUri;
+ $notice->verb = ActivityVerb::POST;
$notice->created = strftime(
'%Y-%m-%d %H:%M:%S',
strtotime($status->created_at)
if (Event::handle('StartNoticeSave', array(&$notice))) {
+ if (empty($notice->conversation)) {
+ $conv = Conversation::create();
+ common_log(LOG_INFO, "No known conversation for status {$statusId} so a new one ({$conv->getID()}) was created.");
+ $notice->conversation = $conv->getID();
+ }
+
$id = $notice->insert();
if ($id === false) {
common_log(LOG_ERR, __METHOD__ . ' - Problem saving notice.');
}
- if (empty($notice->conversation)) {
- $orig = clone($notice);
- $conv = Conversation::create($notice);
- common_log(LOG_INFO, "No known conversation for status {$statusId} so a new one ({$conv->id}) was created.");
- $notice->conversation = $conv->id;
- $notice->update($orig);
- }
-
Event::handle('EndNoticeSave', array($notice));
}
*/
function makeStatusURI($username, $id)
{
- return 'http://twitter.com/#!/'
+ return 'https://twitter.com/'
. $username
. '/status/'
. $id;
$profile->limit(1);
if (!$profile->find(true)) {
- throw new NoResultException($profile);
+ $profile->profileurl = str_replace('https://', 'http://', $profileurl);
+ if (!$profile->find(true)) {
+ throw new NoResultException($profile);
+ }
}
return $profile;
}
protected function ensureProfile($twuser)
{
// check to see if there's already a profile for this user
- $profileurl = 'http://twitter.com/' . $twuser->screen_name;
+ $profileurl = 'https://twitter.com/' . $twuser->screen_name;
try {
$profile = $this->getProfileByUrl($twuser->screen_name, $profileurl);
$this->updateAvatar($twuser, $profile);
$avatar->original = 1; // this is an original/"uploaded" avatar
$avatar->mediatype = $mediatype;
$avatar->filename = $filename;
- $avatar->url = Avatar::url($filename);
$avatar->width = $this->avatarsize;
$avatar->height = $this->avatarsize;
static function atLink($screenName, $fullName, $orig)
{
if (!empty($fullName)) {
- return "<a href='http://twitter.com/#!/{$screenName}' title='{$fullName}'>{$orig}</a>";
+ return "<a href='https://twitter.com/{$screenName}' title='{$fullName}'>{$orig}</a>";
} else {
- return "<a href='http://twitter.com/#!/{$screenName}'>{$orig}</a>";
+ return "<a href='https://twitter.com/{$screenName}'>{$orig}</a>";
}
}
}
foreach ($status->entities->user_mentions as $mention) {
- $flink = Foreign_link::getByForeignID($mention->id, TWITTER_SERVICE);
- if (!empty($flink)) {
- $user = User::getKV('id', $flink->user_id);
- if (!empty($user)) {
- $reply = new Reply();
- $reply->notice_id = $notice->id;
- $reply->profile_id = $user->id;
- $reply->modified = $notice->created;
- common_log(LOG_INFO, __METHOD__ . ": saving reply: notice {$notice->id} to profile {$user->id}");
- $id = $reply->insert();
- }
+ try {
+ $flink = Foreign_link::getByForeignID($mention->id, TWITTER_SERVICE);
+ $user = $flink->getUser();
+ $reply = new Reply();
+ $reply->notice_id = $notice->id;
+ $reply->profile_id = $user->id;
+ $reply->modified = $notice->created;
+ common_log(LOG_INFO, __METHOD__ . ": saving reply: notice {$notice->id} to profile {$user->id}");
+ $id = $reply->insert();
+ } catch (NoSuchUserException $e) {
+ common_log(LOG_WARNING, 'No local user found for Foreign_link with id: '.$mention->id);
+ } catch (NoResultException $e) {
+ common_log(LOG_WARNING, 'No foreign link or profile found for Foreign_link with id: '.$mention->id);
}
}
}
* @param Notice $notice
* @param object $status
*/
- function saveStatusAttachments($notice, $status)
+ function saveStatusAttachments(Notice $notice, $status)
{
if (common_config('attachments', 'process_links')) {
if (!empty($status->entities) && !empty($status->entities->urls)) {
foreach ($status->entities->urls as $url) {
try {
- File::processNew($url->url, $notice->id);
+ File::processNew($url->url, $notice);
} catch (ServerException $e) {
// Could not process attached URL
}