mirror of
https://github.com/friendica/friendica
synced 2025-05-04 07:04:10 +02:00
Merge remote-tracking branch 'upstream/develop' into baseurl
This commit is contained in:
commit
24d2d0481a
55 changed files with 2264 additions and 1152 deletions
|
@ -793,10 +793,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
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Post\Category;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
|
@ -95,9 +96,9 @@ class Item
|
|||
'wall', 'private', 'starred', 'origin', 'parent-origin', 'title', 'body', 'language',
|
||||
'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
|
||||
'quote-uri', 'quote-uri-id', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global',
|
||||
'author-id', 'author-link', 'author-alias', 'author-name', 'author-avatar', 'author-network', 'author-updated', 'author-gsid', 'author-addr', 'author-uri-id',
|
||||
'owner-id', 'owner-link', 'owner-alias', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated',
|
||||
'causer-id', 'causer-link', 'causer-alias', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network',
|
||||
'author-id', 'author-link', 'author-alias', 'author-name', 'author-avatar', 'author-network', 'author-updated', 'author-gsid', 'author-baseurl', 'author-addr', 'author-uri-id',
|
||||
'owner-id', 'owner-link', 'owner-alias', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated', 'owner-gsid',
|
||||
'causer-id', 'causer-link', 'causer-alias', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network', 'causer-gsid',
|
||||
'contact-id', 'contact-uid', 'contact-link', 'contact-name', 'contact-avatar',
|
||||
'writable', 'self', 'cid', 'alias',
|
||||
'event-created', 'event-edited', 'event-start', 'event-finish',
|
||||
|
@ -1509,10 +1510,13 @@ class Item
|
|||
return;
|
||||
}
|
||||
|
||||
$uids = Tag::getUIDListByURIId($item['uri-id']);
|
||||
foreach ($uids as $uid) {
|
||||
foreach (Tag::getUIDListByURIId($item['uri-id']) as $uid => $tags) {
|
||||
$stored = self::storeForUserByUriId($item['uri-id'], $uid, ['post-reason' => self::PR_TAG]);
|
||||
Logger::info('Stored item for users', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
|
||||
foreach ($tags as $tag) {
|
||||
$stored = Category::storeFileByURIId($item['uri-id'], $uid, Category::SUBCRIPTION, $tag);
|
||||
Logger::debug('Stored tag subscription for user', ['uri-id' => $item['uri-id'], 'uid' => $uid, $tag, 'stored' => $stored]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -453,12 +453,10 @@ class Post
|
|||
AND (NOT `causer-blocked` OR `causer-id` = ? OR `causer-id` IS NULL) AND NOT `contact-blocked`
|
||||
AND ((NOT `contact-readonly` AND NOT `contact-pending` AND (`contact-rel` IN (?, ?)))
|
||||
OR `self` OR `contact-uid` = ?)
|
||||
AND NOT `" . $view . "`.`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `uid` = ? AND `hidden`)
|
||||
AND NOT `author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `blocked` AND `cid` = `author-id`)
|
||||
AND NOT `owner-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `blocked` AND `cid` = `owner-id`)
|
||||
AND NOT `author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `ignored` AND `cid` = `author-id`)
|
||||
AND NOT `owner-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `ignored` AND `cid` = `owner-id`)",
|
||||
0, Contact::SHARING, Contact::FRIEND, 0, $uid, $uid, $uid, $uid, $uid]);
|
||||
AND NOT EXISTS(SELECT `uri-id` FROM `post-user` WHERE `uid` = ? AND `uri-id` = " . DBA::quoteIdentifier($view) . ".`uri-id` AND `hidden`)
|
||||
AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` IN (`author-id`, `owner-id`) AND (`blocked` OR `ignored`))
|
||||
AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = ? AND `gsid` IN (`author-gsid`, `owner-gsid`, `causer-gsid`) AND `ignored`)",
|
||||
0, Contact::SHARING, Contact::FRIEND, 0, $uid, $uid, $uid]);
|
||||
|
||||
$select_string = implode(', ', array_map([DBA::class, 'quoteIdentifier'], $selected));
|
||||
|
||||
|
|
|
@ -33,9 +33,10 @@ use Friendica\Model\Tag;
|
|||
*/
|
||||
class Category
|
||||
{
|
||||
const UNKNOWN = 0;
|
||||
const CATEGORY = 3;
|
||||
const FILE = 5;
|
||||
const UNKNOWN = 0;
|
||||
const CATEGORY = 3;
|
||||
const FILE = 5;
|
||||
const SUBCRIPTION = 10;
|
||||
|
||||
/**
|
||||
* Delete all categories and files from a given uri-id and user
|
||||
|
@ -80,7 +81,7 @@ class Category
|
|||
{
|
||||
$file_text = '';
|
||||
|
||||
$tags = DBA::selectToArray('category-view', ['type', 'name'], ['uri-id' => $uri_id, 'uid' => $uid]);
|
||||
$tags = DBA::selectToArray('category-view', ['type', 'name'], ['uri-id' => $uri_id, 'uid' => $uid, 'type' => [Category::FILE, Category::CATEGORY]]);
|
||||
foreach ($tags as $tag) {
|
||||
if ($tag['type'] == self::CATEGORY) {
|
||||
$file_text .= '<' . $tag['name'] . '>';
|
||||
|
@ -177,12 +178,7 @@ class Category
|
|||
continue;
|
||||
}
|
||||
|
||||
DBA::replace('post-category', [
|
||||
'uri-id' => $uri_id,
|
||||
'uid' => $uid,
|
||||
'type' => self::FILE,
|
||||
'tid' => $tagid
|
||||
]);
|
||||
self::storeByURIId($uri_id, $uid, self::FILE, $tagid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,13 +189,18 @@ class Category
|
|||
}
|
||||
}
|
||||
|
||||
public static function storeFileByURIId(int $uri_id, int $uid, int $type, string $file)
|
||||
public static function storeFileByURIId(int $uri_id, int $uid, int $type, string $file, string $url = ''): bool
|
||||
{
|
||||
$tagid = Tag::getID($file);
|
||||
$tagid = Tag::getID($file, $url);
|
||||
if (empty($tagid)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return self::storeByURIId($uri_id, $uid, $type, $tagid);
|
||||
}
|
||||
|
||||
private static function storeByURIId(int $uri_id, int $uid, int $type, int $tagid): bool
|
||||
{
|
||||
return DBA::replace('post-category', [
|
||||
'uri-id' => $uri_id,
|
||||
'uid' => $uid,
|
||||
|
|
|
@ -133,14 +133,14 @@ class UserNotification
|
|||
public static function setNotification(int $uri_id, int $uid)
|
||||
{
|
||||
$fields = ['id', 'uri-id', 'parent-uri-id', 'uid', 'body', 'parent', 'gravity', 'vid', 'gravity',
|
||||
'contact-id', 'author-id', 'owner-id', 'causer-id',
|
||||
'contact-id', 'author-id', 'author-gsid', 'owner-id', 'owner-gsid', 'causer-id', 'causer-gsid',
|
||||
'private', 'thr-parent', 'thr-parent-id', 'parent-uri-id', 'parent-uri', 'verb'];
|
||||
$item = Post::selectFirst($fields, ['uri-id' => $uri_id, 'uid' => $uid, 'origin' => false]);
|
||||
if (!DBA::isResult($item)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$parent = Post::selectFirstPost(['author-id', 'owner-id', 'causer-id'], ['uri-id' => $item['parent-uri-id']]);
|
||||
$parent = Post::selectFirstPost(['author-id', 'author-gsid', 'owner-id', 'owner-gsid', 'causer-id', 'causer-gsid',], ['uri-id' => $item['parent-uri-id']]);
|
||||
if (!DBA::isResult($parent)) {
|
||||
return;
|
||||
}
|
||||
|
@ -195,6 +195,13 @@ class UserNotification
|
|||
}
|
||||
}
|
||||
|
||||
foreach (array_unique([$parent['author-gsid'], $parent['owner-gsid'], $parent['causer-gsid'], $item['author-gsid'], $item['owner-gsid'], $item['causer-gsid']]) as $gsid) {
|
||||
if ($gsid && DI::userGServer()->isIgnoredByUser($uid, $gsid)) {
|
||||
Logger::debug('Server is ignored by user', ['uid' => $uid, 'gsid' => $gsid, 'uri-id' => $item['uri-id']]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$user = User::getById($uid, ['account-type', 'account_removed', 'account_expired']);
|
||||
if (in_array($user['account-type'], [User::ACCOUNT_TYPE_COMMUNITY, User::ACCOUNT_TYPE_RELAY])) {
|
||||
return;
|
||||
|
|
|
@ -37,6 +37,7 @@ use Friendica\DI;
|
|||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Security\PermissionSet\Entity\PermissionSet;
|
||||
|
@ -93,10 +94,11 @@ class Profile
|
|||
/**
|
||||
* Update a profile entry and distribute the changes if needed
|
||||
*
|
||||
* @param array $fields Profile fields to update
|
||||
* @param integer $uid User id
|
||||
* @param array $fields Profile fields to update
|
||||
* @param integer $uid User id
|
||||
*
|
||||
* @return boolean Whether update was successful
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function update(array $fields, int $uid): bool
|
||||
{
|
||||
|
@ -116,10 +118,6 @@ class Profile
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($old_owner['name'] != $owner['name']) {
|
||||
User::update(['username' => $owner['name']], $uid);
|
||||
}
|
||||
|
||||
$profile_fields = ['postal-code', 'dob', 'prv_keywords', 'homepage'];
|
||||
foreach ($profile_fields as $field) {
|
||||
if ($old_owner[$field] != $owner[$field]) {
|
||||
|
|
|
@ -828,12 +828,13 @@ class Tag
|
|||
public static function getUIDListByURIId(int $uriId): array
|
||||
{
|
||||
$uids = [];
|
||||
$tags = self::getByURIId($uriId, [self::HASHTAG]);
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
$uids = array_merge($uids, self::getUIDListByTag(self::TAG_CHARACTER[self::HASHTAG] . $tag['name']));
|
||||
foreach (self::getByURIId($uriId, [self::HASHTAG]) as $tag) {
|
||||
foreach (self::getUIDListByTag(self::TAG_CHARACTER[self::HASHTAG] . $tag['name']) as $uid) {
|
||||
$uids[$uid][] = $tag['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique($uids);
|
||||
return $uids;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Module;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Object\Image;
|
||||
|
@ -1328,33 +1329,18 @@ class User
|
|||
/**
|
||||
* Update a user entry and distribute the changes if needed
|
||||
*
|
||||
* @param array $fields
|
||||
* @param array $fields
|
||||
* @param integer $uid
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function update(array $fields, int $uid): bool
|
||||
{
|
||||
$old_owner = self::getOwnerDataById($uid);
|
||||
if (empty($old_owner)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!DBA::update('user', $fields, ['uid' => $uid])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$update = Contact::updateSelfFromUserID($uid);
|
||||
|
||||
$owner = self::getOwnerDataById($uid);
|
||||
if (empty($owner)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($old_owner['name'] != $owner['name']) {
|
||||
Profile::update(['name' => $owner['name']], $uid);
|
||||
}
|
||||
|
||||
if ($update) {
|
||||
if (Contact::updateSelfFromUserID($uid)) {
|
||||
Profile::publishUpdate($uid);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue