use Friendica\BaseDataTransferObject;
use Friendica\Content\ContactSelector;
use Friendica\Content\Text\BBCode;
+use Friendica\Core\Protocol;
+use Friendica\Model\Contact;
+use Friendica\Util\Proxy;
/**
* @see https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/user-object
/** @var string */
protected $withheld_scope;
+ /**
+ * Missing fields:
+ *
+ * - profile_sidebar_fill_color
+ * - profile_link_color
+ * - profile_background_color
+ */
+
/**
* @param array $publicContact Full contact table record with uid = 0
* @param array $apcontact Optional full apcontact table record
*/
public function __construct(array $publicContact, array $apcontact = [], array $userContact = [], $skip_status = false, $include_user_entities = true)
{
+ $uid = $userContact['uid'] ?? 0;
+
$this->id = (int)$publicContact['id'];
$this->id_str = (string) $publicContact['id'];
- $this->name = $publicContact['name'];
+ $this->name = $publicContact['name'] ?: $publicContact['nick'];
$this->screen_name = $publicContact['nick'] ?: $publicContact['name'];
$this->location = $publicContact['location'] ?:
ContactSelector::networkToName($publicContact['network'], $publicContact['url'], $publicContact['protocol']);
unset($this->entities);
}
$this->description = BBCode::toPlaintext($publicContact['about']);
- $this->profile_image_url_https = $userContact['avatar'] ?? $publicContact['avatar'];
+ $this->profile_image_url_https = Contact::getAvatarUrlForUrl($publicContact['url'], $uid, Proxy::SIZE_MICRO);
$this->protected = false;
$this->followers_count = $apcontact['followers_count'] ?? 0;
$this->friends_count = $apcontact['following_count'] ?? 0;
$this->listed_count = 0;
$this->created_at = api_date($publicContact['created']);
$this->favourites_count = 0;
- $this->verified = false;
+ $this->verified = $uid != 0;
$this->statuses_count = $apcontact['statuses_count'] ?? 0;
$this->profile_banner_url = '';
$this->default_profile = false;
unset($this->withheld_scope);
// Deprecated
- $this->profile_image_url = $userContact['avatar'] ?? $publicContact['avatar'];
- $this->profile_image_url_profile_size = $publicContact['thumb'];
- $this->profile_image_url_large = $publicContact['photo'];
+ $this->profile_image_url = Contact::getAvatarUrlForUrl($publicContact['url'], $uid, Proxy::SIZE_MICRO);
+ $this->profile_image_url_profile_size = Contact::getAvatarUrlForUrl($publicContact['url'], $uid, Proxy::SIZE_THUMB);
+ $this->profile_image_url_large = Contact::getAvatarUrlForUrl($publicContact['url'], $uid, Proxy::SIZE_LARGE);
$this->utc_offset = 0;
$this->time_zone = 'UTC';
$this->geo_enabled = false;
$this->contributors_enabled = false;
$this->is_translator = false;
$this->is_translation_enabled = false;
- $this->following = false;
+ $this->following = in_array($userContact['rel'] ?? Contact::NOTHING, [Contact::FOLLOWER, Contact::FRIEND]);
$this->follow_request_sent = false;
$this->statusnet_blocking = false;
$this->notifications = false;
// Friendica-specific
- $this->uid = (int)$userContact['uid'] ?? 0;
- $this->cid = (int)$userContact['id'] ?? 0;
+ $this->uid = (int)$uid;
+ $this->cid = (int)($userContact['id'] ?? 0);
$this->pid = (int)$publicContact['id'];
- $this->self = (boolean)$userContact['self'] ?? false;
- $this->network = $publicContact['network'];
+ $this->self = (boolean)($userContact['self'] ?? false);
+ $this->network = $publicContact['network'] ?: Protocol::DFRN;
$this->statusnet_profile_url = $publicContact['url'];
}
}