X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FContact.php;h=47b8ad4cfdd5a8ecefdc00c0e72c5d1db12c7476;hb=9cbad559a1bda6f9ff87b094d01c7511f663a893;hp=23e1f2cbff2b30b795b309e408a76fdb1c1e22ae;hpb=a2fce0e89db895b278df787ea1a4915fc2035a5d;p=friendica.git diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 23e1f2cbff..47b8ad4cfd 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -22,6 +22,7 @@ namespace Friendica\Model; use Friendica\Contact\Avatar; +use Friendica\Contact\Header; use Friendica\Contact\Introduction\Exception\IntroductionNotFoundException; use Friendica\Contact\LocalRelationship\Entity\LocalRelationship; use Friendica\Content\Conversation as ConversationContent; @@ -221,6 +222,11 @@ class Contact Contact\User::insertForContactArray($contact); + if ((empty($contact['baseurl']) || empty($contact['gsid'])) && Probe::isProbable($contact['network'])) { + Logger::debug('Update missing baseurl', ['id' => $contact['id'], 'url' => $contact['url'], 'callstack' => System::callstack(4, 0, true)]); + UpdateContact::add(['priority' => Worker::PRIORITY_MEDIUM, 'dont_fork' => true], $contact['id']); + } + return $contact['id']; } @@ -527,6 +533,17 @@ class Contact return self::isSharing($cid, $uid, $strict); } + /** + * Checks if the provided public contact id has got followers on this system + * + * @param integer $cid + * @return boolean + */ + public static function hasFollowers(int $cid): bool + { + return DBA::exists('account-user-view', ["`pid` = ? AND `uid` != ? AND `rel` IN (?, ?)", $cid, 0, self::SHARING, self::FRIEND]); + } + /** * Get the basepath for a given contact link * @@ -733,7 +750,7 @@ class Contact $user = DBA::selectFirst( 'user', ['uid', 'username', 'nickname', 'pubkey', 'prvkey'], - ['uid' => $uid, 'account_expired' => false] + ['uid' => $uid, 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false] ); if (!DBA::isResult($user)) { return false; @@ -787,10 +804,10 @@ class Contact /** * Updates the self-contact for the provided user id * - * @param int $uid - * @param bool $update_avatar Force the avatar update + * @param int $uid + * @param bool $update_avatar Force the avatar update * @return bool "true" if updated - * @throws HTTPException\InternalServerErrorException + * @throws \Exception */ public static function updateSelfFromUserID(int $uid, bool $update_avatar = false): bool { @@ -805,7 +822,7 @@ class Contact } $fields = ['uid', 'username', 'nickname', 'page-flags', 'account-type', 'prvkey', 'pubkey']; - $user = DBA::selectFirst('user', $fields, ['uid' => $uid, 'account_expired' => false]); + $user = DBA::selectFirst('user', $fields, ['uid' => $uid, 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]); if (!DBA::isResult($user)) { return false; } @@ -1160,6 +1177,7 @@ class Contact } $pm_url = ''; + $mention_url = ''; $status_link = ''; $photos_link = ''; @@ -1180,8 +1198,23 @@ class Contact $pm_url = 'message/new/' . $contact['id']; } + if ($contact['contact-type'] == Contact::TYPE_COMMUNITY) { + $mention_label = DI::l10n()->t('Post to group'); + $mention_url = 'compose/0?body=!' . $contact['addr']; + } else { + $mention_label = DI::l10n()->t('Mention'); + $mention_url = 'compose/0?body=@' . $contact['addr']; + } + $contact_url = 'contact/' . $contact['id']; - $posts_link = 'contact/' . $contact['id'] . '/conversations'; + + if ($contact['contact-type'] == Contact::TYPE_COMMUNITY) { + $network_label = DI::l10n()->t('View group'); + $network_url = 'network/group/' . $contact['id']; + } else { + $network_label = DI::l10n()->t('Network Posts'); + $network_url = 'contact/' . $contact['id'] . '/conversations'; + } $follow_link = ''; $unfollow_link = ''; @@ -1197,24 +1230,30 @@ class Contact * Menu array: * "name" => [ "Label", "link", (bool)Should the link opened in a new tab? ] */ + + if (empty($contact['uid'])) { $menu = [ 'profile' => [DI::l10n()->t('View Profile'), $profile_link, true], - 'network' => [DI::l10n()->t('Network Posts'), $posts_link, false], + 'network' => [$network_label, $network_url, false], 'edit' => [DI::l10n()->t('View Contact'), $contact_url, false], 'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link, true], 'unfollow' => [DI::l10n()->t('Unfollow'), $unfollow_link, true], + 'mention' => [DI::l10n()->t('Mention'), DI::l10n()->t('Post to group'), $mention_url, false], + 'group' => [DI::l10n()->t('View group'), $group_link, $contact['forum'], true], + 'self' => [$contact['self'] ?? false, true], ]; } else { $menu = [ 'status' => [DI::l10n()->t('View Status'), $status_link, true], 'profile' => [DI::l10n()->t('View Profile'), $profile_link, true], 'photos' => [DI::l10n()->t('View Photos'), $photos_link, true], - 'network' => [DI::l10n()->t('Network Posts'), $posts_link, false], + 'network' => [$network_label, $network_url, false], 'edit' => [DI::l10n()->t('View Contact'), $contact_url, false], 'pm' => [DI::l10n()->t('Send PM'), $pm_url, false], 'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link, true], 'unfollow' => [DI::l10n()->t('Unfollow'), $unfollow_link, true], + 'mention' => [$mention_label, $mention_url, false], ]; if (!empty($contact['pending'])) { @@ -1371,6 +1410,7 @@ class Contact $fields = [ 'uid' => $uid, 'url' => $data['url'], + 'baseurl' => $data['baseurl'] ?? '', 'nurl' => Strings::normaliseLink($data['url']), 'network' => $data['network'], 'created' => DateTimeFormat::utcNow(), @@ -1899,13 +1939,7 @@ class Contact switch ($platform) { case 'friendica': case 'friendika': - /** - * Picture credits - * @author Lostinlight - * @license CC0 https://creativecommons.org/share-your-work/public-domain/cc0/ - * @link https://gitlab.com/lostinlight/per_aspera_ad_astra/-/blob/master/friendica-404/friendica-promo-bubbles.jpg - */ - $header = DI::baseUrl() . '/images/friendica-banner.jpg'; + $header = DI::baseUrl() . (new Header(DI::config()))->getMastodonBannerPath(); break; case 'diaspora': /** @@ -3186,7 +3220,7 @@ class Contact return false; } - $fields = ['id', 'url', 'name', 'nick', 'avatar', 'photo', 'network', 'blocked']; + $fields = ['id', 'url', 'name', 'nick', 'avatar', 'photo', 'network', 'blocked', 'baseurl']; $pub_contact = DBA::selectFirst('contact', $fields, ['id' => $datarray['author-id']]); if (!DBA::isResult($pub_contact)) { // Should never happen @@ -3257,6 +3291,7 @@ class Contact 'created' => DateTimeFormat::utcNow(), 'url' => $url, 'nurl' => Strings::normaliseLink($url), + 'baseurl' => $pub_contact['baseurl'] ?? '', 'name' => $name, 'nick' => $nick, 'network' => $network,