namespace Friendica\Model;
+use Exception;
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;
use Friendica\Content\Pager;
use Friendica\Content\Text\HTML;
use Friendica\DI;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
-use Friendica\Network\HTTPException;
+use Friendica\Network\HTTPException\NotFoundException;
+use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\Activity;
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array
- * @throws \Exception
+ * @throws Exception
*/
public static function selectToArray(array $fields = [], array $condition = [], array $params = []): array
{
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array|bool
- * @throws \Exception
+ * @throws Exception
*/
public static function selectFirst(array $fields = [], array $condition = [], array $params = [])
{
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array
- * @throws \Exception
+ * @throws Exception
*/
public static function selectAccountToArray(array $fields = [], array $condition = [], array $params = []): array
{
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array|bool
- * @throws \Exception
+ * @throws Exception
*/
public static function selectFirstAccount(array $fields = [], array $condition = [], array $params = [])
{
* @param int $duplicate_mode Do an update on a duplicate entry
*
* @return int id of the created contact
- * @throws \Exception
+ * @throws Exception
*/
public static function insert(array $fields, int $duplicate_mode = Database::INSERT_DEFAULT): int
{
* @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate, false = don't update identical fields)
*
* @return boolean was the update successful?
- * @throws \Exception
+ * @throws Exception
* @todo Let's get rid of boolean type of $old_fields
*/
public static function update(array $fields, array $condition, $old_fields = []): bool
* @param integer $id Contact ID
* @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise
- * @throws \Exception
+ * @throws Exception
*/
public static function getAccountById(int $id, array $fields = [])
{
* @param integer $id Contact ID
* @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise
- * @throws \Exception
+ * @throws Exception
*/
public static function getById(int $id, array $fields = [])
{
* @param integer $uri_id uri-id of the contact
* @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise
- * @throws \Exception
+ * @throws Exception
*/
public static function getByUriId(int $uri_id, array $fields = [])
{
*
* @return array all remote contacts
*
- * @throws \Exception
+ * @throws Exception
*/
public static function getVisitorByUrl(string $url, array $fields = ['id', 'uid']): array
{
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact id a follower?
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isFollower(int $cid, int $uid, bool $strict = false): bool
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact id a follower?
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isFollowerByURL(string $url, int $uid, bool $strict = false): bool
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact sharing with given user?
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isSharing(int $cid, int $uid, bool $strict = false): bool
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact url being followed?
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isSharingByURL(string $url, int $uid, bool $strict = false): bool
* @param boolean $dont_update Don't update the contact
*
* @return string basepath
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getBasepath(string $url, bool $dont_update = false): string
/**
* Check if the given contact ID is on the same server
*
- * @param string $url The contact link
+ * @param int $cid The contact link
* @return boolean Is it the same server?
*/
public static function isLocalById(int $cid): bool
* @param integer $uid User ID
*
* @return integer|boolean Public contact id for given user id
- * @throws \Exception
+ * @throws Exception
*/
public static function getPublicIdByUserId(int $uid)
{
* @param int $uid User ID
*
* @return array with public and user's contact id
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getPublicAndUserContactID(int $cid, int $uid): array
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return array with public and user's contact id
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
private static function legacyGetPublicAndUserContactID(int $cid, int $uid): array
* @param array $fields The selected fields for the contact
* @return array The contact details
*
- * @throws \Exception
+ * @throws Exception
*/
public static function getContactForUser(int $cid, int $uid, array $fields = []): array
{
*
* @param int $uid
* @return bool Operation success
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public static function createSelfFromUserId(int $uid): bool
{
* @param int $uid
* @param bool $update_avatar Force the avatar update
* @return bool "true" if updated
- * @throws \Exception
+ * @throws Exception
*/
public static function updateSelfFromUserID(int $uid, bool $update_avatar = false): bool
{
*
* @param int $id contact id
* @return void
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public static function remove(int $id)
{
*
* @param array $contact Target user-specific contact (uid != 0) array
* @return void
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function unfollow(array $contact): void
*
* @param array $contact User-specific contact array (uid != 0) to revoke the follow from
* @return void
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function revokeFollow(array $contact): void
*
* @param array $contact User-specific contact (uid != 0) array
* @return void
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function terminateFriendship(array $contact)
*
* @param array $contact contact to mark for archival
* @return void
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public static function markForArchival(array $contact)
{
*
* @param array $contact contact to be unmarked for archival
* @return void
- * @throws \Exception
+ * @throws Exception
*/
public static function unmarkForArchival(array $contact)
{
* @param array $contact contact
* @param int $uid Visitor user id
* @return array
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function photoMenu(array $contact, int $uid): array
* @param array $default Default value for creating the contact when everything else fails
*
* @return integer Contact ID
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getIdForURL(string $url = null, int $uid = 0, $update = null, array $default = []): int
if ($data['network'] == Protocol::DIASPORA) {
try {
DI::dsprContact()->updateFromProbeArray($data);
- } catch (HTTPException\NotFoundException $e) {
+ } catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
try {
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
- } catch (HTTPException\NotFoundException $e) {
+ } catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
* @param int $cid contact id
*
* @return boolean Is the contact archived?
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public static function isArchived(int $cid): bool
{
*
* @param int $cid contact id
* @return boolean Is the contact blocked?
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public static function isBlocked(int $cid): bool
{
*
* @param int $cid contact id
* @return boolean Is the contact hidden?
- * @throws \Exception
+ * @throws Exception
*/
public static function isHidden(int $cid): bool
{
* @param bool $only_media Only display media content
* @param string $last_created Newest creation date, used for paging
* @return string posts in HTML
- * @throws \Exception
+ * @throws Exception
*/
public static function getPostsFromUrl(string $contact_url, int $uid, bool $only_media = false, string $last_created = null): string
{
* @param bool $only_media Only display media content
* @param string $last_created Newest creation date, used for paging
* @return string posts in HTML
- * @throws \Exception
+ * @throws Exception
*/
public static function getPostsFromId(int $cid, int $uid, bool $only_media = false, string $last_created = null): string
{
* @param int $update Update mode
* @param int $parent Item parent ID for the update mode
* @return string posts in HTML
- * @throws \Exception
+ * @throws Exception
*/
public static function getThreadsFromId(int $cid, int $uid, int $update = 0, int $parent = 0, string $last_created = ''): string
{
* @param bool $create_cache Enforces the creation of cached avatar fields
*
* @return void
- * @throws HTTPException\InternalServerErrorException
- * @throws HTTPException\NotFoundException
+ * @throws InternalServerErrorException
+ * @throws NotFoundException
* @throws \ImagickException
*/
public static function updateAvatar(int $cid, string $avatar, bool $force = false, bool $create_cache = false)
* @param integer $id contact id
* @param string $url The new URL to use for polling
*
- * @throws \Exception
+ * @throws Exception
*/
public static function updatePollUrl(int $id, string $url)
{
* @param string $url The profile URL of the contact
* @param array $fields The fields that are updated
*
- * @throws \Exception
+ * @throws Exception
*/
private static function updateContact(int $id, int $uid, int $uri_id, string $url, array $fields)
{
* @param string $nurl Normalised contact url
* @param integer $uid User id
* @return boolean
- * @throws \Exception
+ * @throws Exception
*/
public static function removeDuplicates(string $nurl, int $uid)
{
* @param integer $id contact id
* @param string $network Optional network we are probing for
* @return boolean
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function updateFromProbe(int $id, string $network = ''): bool
if ($data['network'] == Protocol::DIASPORA) {
try {
DI::dsprContact()->updateFromProbeArray($data);
- } catch (HTTPException\NotFoundException $e) {
+ } catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
try {
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
- } catch (HTTPException\NotFoundException $e) {
+ } catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
* @param integer $id contact id
* @param array $ret Probed data
* @return boolean
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
private static function updateFromProbeArray(int $id, array $ret): bool
/**
* Updates contact record by provided URL
*
- * @param integer $url contact url
- * @return integer Contact id
- * @throws HTTPException\InternalServerErrorException
+ * @param string $url contact url
+ * @return int Contact id
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function updateFromProbeByURL(string $url): int
* @param string $url The profile URL of the contact
* @param string $network
* @return array
- * @throws HTTPException\InternalServerErrorException
- * @throws HTTPException\NotFoundException
+ * @throws InternalServerErrorException
+ * @throws NotFoundException
* @throws \ImagickException
*/
public static function createFromProbeForUser(int $uid, string $url, string $network = ''): array
* @param bool $sharing True: Contact is now sharing with Owner; False: Contact is now following Owner (default)
* @param string $note Introduction additional message
* @return bool|null True: follow request is accepted; False: relationship is rejected; Null: relationship is pending
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function addRelationship(array $importer, array $contact, array $datarray, bool $sharing = false, string $note = '')
* @param array $contact User-specific contact (uid != 0) array
* @param bool $delete Delete if set, otherwise set relation to "nothing" when contact had been a follower
* @return void
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function removeFollower(array $contact, bool $delete = true)
*
* @param array $contact User-specific contact (uid != 0) array
* @param bool $delete Delete if set, otherwise set relation to "nothing" when contact had been a sharer
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
*/
public static function removeSharer(array $contact, bool $delete = true)
{
*
* @param array $contact_ids Contact id list
* @return array
- * @throws \Exception
+ * @throws Exception
*/
public static function pruneUnavailable(array $contact_ids): array
{
* @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function magicLink(string $contact_url, string $url = ''): string
* @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function magicLinkById(int $cid, string $url = ''): string
* @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function magicLinkByContact(array $contact, string $url = ''): string
* @param array $condition
*
* @return bool
- * @throws \Exception
+ * @throws Exception
*/
public static function exists(array $condition): bool
{
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\ItemURI;
+use Friendica\Network\HTTPException\InternalServerErrorException;
use PDOException;
/**
* @param boolean $blocked Is the contact blocked or unblocked?
* @param boolean $only_set Only set the block flag, don't execute any block transmission
* @return void
- * @throws \Exception
+ * @throws Exception
*/
public static function setBlocked(int $cid, int $uid, bool $blocked, bool $only_set = false)
{
* @param int $uid User ID
*
* @return boolean is the contact id blocked for the given user?
- * @throws \Exception
+ * @throws Exception
*/
public static function isBlocked(int $cid, int $uid): bool
{
* @param int $uid User ID
* @param boolean $ignored Is the contact ignored or unignored?
* @return void
- * @throws \Exception
+ * @throws Exception
*/
public static function setIgnored(int $cid, int $uid, bool $ignored)
{
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return boolean is the contact id ignored for the given user?
- * @throws \Exception
+ * @throws Exception
*/
public static function isIgnored(int $cid, int $uid): bool
{
* @param int $uid User ID
* @param boolean $collapsed are the contact's posts collapsed or uncollapsed?
* @return void
- * @throws \Exception
+ * @throws Exception
*/
public static function setCollapsed(int $cid, int $uid, bool $collapsed)
{
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return boolean is the contact id blocked for the given user?
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isCollapsed(int $cid, int $uid): bool
* @param int $uid User ID
* @param int $frequency Type of post frequency in channels
* @return void
- * @throws \Exception
+ * @throws Exception
*/
public static function setChannelFrequency(int $cid, int $uid, int $frequency)
{
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return int Type of post frequency in channels
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getChannelFrequency(int $cid, int $uid): int
/**
* Set the channel only value for contact id and user id
*
- * @param int $cid Either public contact id or user's contact id
- * @param int $uid User ID
- * @param int $isChannelOnly Is channel only
+ * @param int $cid Either public contact id or user's contact id
+ * @param int $uid User ID
+ * @param bool $isChannelOnly Is channel only
* @return void
- * @throws \Exception
+ * @throws Exception
*/
public static function setChannelOnly(int $cid, int $uid, bool $isChannelOnly)
{
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return bool Contact is channel only
- * @throws HTTPException\InternalServerErrorException
+ * @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getChannelOnly(int $cid, int $uid): bool
* @param int $uid User ID
* @param boolean $blocked Is the user blocked or unblocked by the contact?
* @return void
- * @throws \Exception
+ * @throws Exception
*/
public static function setIsBlocked(int $cid, int $uid, bool $blocked)
{
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return boolean Is the user blocked or unblocked by the contact?
- * @throws \Exception
+ * @throws Exception
*/
public static function isIsBlocked(int $cid, int $uid): bool
{