mirror of
https://github.com/friendica/friendica
synced 2024-12-23 00:00:21 +00:00
Use the owner, not the author
This commit is contained in:
parent
ca32134830
commit
fdaff43039
5 changed files with 25 additions and 25 deletions
|
@ -1305,16 +1305,16 @@ CREATE TABLE IF NOT EXISTS `post-delivery-data` (
|
|||
--
|
||||
CREATE TABLE IF NOT EXISTS `post-engagement` (
|
||||
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
|
||||
`author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
|
||||
`owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
|
||||
`contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
|
||||
`created` datetime COMMENT '',
|
||||
`comments` mediumint unsigned COMMENT 'Number of comments',
|
||||
`activities` mediumint unsigned COMMENT 'Number of activities (like, dislike, ...)',
|
||||
PRIMARY KEY(`uri-id`),
|
||||
INDEX `author-id` (`author-id`),
|
||||
INDEX `owner-id` (`owner-id`),
|
||||
INDEX `created` (`created`),
|
||||
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
|
||||
FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
|
||||
FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Engagement data per post';
|
||||
|
||||
--
|
||||
|
|
|
@ -7,9 +7,9 @@ Fields
|
|||
------
|
||||
|
||||
| Field | Description | Type | Null | Key | Default | Extra |
|
||||
| ------------ | --------------------------------------------------------------- | ------------------ | ---- | --- | ------- | ----- |
|
||||
| ------------ | --------------------------------------------------------- | ------------------ | ---- | --- | ------- | ----- |
|
||||
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | PRI | NULL | |
|
||||
| author-id | Link to the contact table with uid=0 of the author of this item | int unsigned | NO | | 0 | |
|
||||
| owner-id | Item owner | int unsigned | NO | | 0 | |
|
||||
| contact-type | Person, organisation, news, community, relay | tinyint | NO | | 0 | |
|
||||
| created | | datetime | YES | | NULL | |
|
||||
| comments | Number of comments | mediumint unsigned | YES | | NULL | |
|
||||
|
@ -19,9 +19,9 @@ Indexes
|
|||
------------
|
||||
|
||||
| Name | Fields |
|
||||
| --------- | --------- |
|
||||
| -------- | -------- |
|
||||
| PRIMARY | uri-id |
|
||||
| author-id | author-id |
|
||||
| owner-id | owner-id |
|
||||
| created | created |
|
||||
|
||||
Foreign Keys
|
||||
|
@ -30,6 +30,6 @@ Foreign Keys
|
|||
| Field | Target Table | Target Field |
|
||||
|-------|--------------|--------------|
|
||||
| uri-id | [item-uri](help/database/db_item-uri) | id |
|
||||
| author-id | [contact](help/database/db_contact) | id |
|
||||
| owner-id | [contact](help/database/db_contact) | id |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -64,7 +64,7 @@ class Engagement
|
|||
return;
|
||||
}
|
||||
|
||||
$parent = Post::selectFirst(['created', 'author-id', 'uid', 'private', 'contact-contact-type'], ['uri-id' => $item['parent-uri-id']]);
|
||||
$parent = Post::selectFirst(['created', 'owner-id', 'uid', 'private', 'contact-contact-type'], ['uri-id' => $item['parent-uri-id']]);
|
||||
if ($parent['private'] != Item::PUBLIC) {
|
||||
Logger::debug('Non public posts are not stored', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'uid' => $parent['uid'], 'private' => $parent['private']]);
|
||||
return;
|
||||
|
@ -77,7 +77,7 @@ class Engagement
|
|||
|
||||
$engagement = [
|
||||
'uri-id' => $item['parent-uri-id'],
|
||||
'author-id' => $parent['author-id'],
|
||||
'owner-id' => $parent['owner-id'],
|
||||
'contact-type' => $parent['contact-contact-type'],
|
||||
'created' => $parent['created'],
|
||||
'comments' => DBA::count('post', ['parent-uri-id' => $item['parent-uri-id'], 'gravity' => Item::GRAVITY_COMMENT]),
|
||||
|
|
|
@ -245,13 +245,13 @@ class Channel extends BaseModule
|
|||
} elseif (self::$content == self::FORYOU) {
|
||||
$cid = Contact::getPublicIdByUserId(DI::userSession()->getLocalUserId());
|
||||
|
||||
$condition = ["(`author-id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `thread-score` > ?) OR
|
||||
((`comments` >= ? OR `activities` >= ?) AND `author-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?))) OR
|
||||
( `author-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?) AND `notify_new_posts`)))",
|
||||
$condition = ["(`owner-id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `thread-score` > ?) OR
|
||||
((`comments` >= ? OR `activities` >= ?) AND `owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?))) OR
|
||||
( `owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?) AND `notify_new_posts`)))",
|
||||
$cid, self::getMedianThreadScore($cid, 4), self::getMedianComments(4), self::getMedianActivities(4), DI::userSession()->getLocalUserId(), Contact::FRIEND, Contact::SHARING,
|
||||
DI::userSession()->getLocalUserId(), Contact::FRIEND, Contact::SHARING];
|
||||
} elseif (self::$content == self::FOLLOWERS) {
|
||||
$condition = ["`author-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` = ?)", DI::userSession()->getLocalUserId(), Contact::FOLLOWER];
|
||||
$condition = ["`owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` = ?)", DI::userSession()->getLocalUserId(), Contact::FOLLOWER];
|
||||
}
|
||||
|
||||
if ((self::$content != self::WHATSHOT) && !is_null(self::$accountType)) {
|
||||
|
|
|
@ -1327,7 +1327,7 @@ return [
|
|||
"comment" => "Engagement data per post",
|
||||
"fields" => [
|
||||
"uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
|
||||
"author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Link to the contact table with uid=0 of the author of this item"],
|
||||
"owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Item owner"],
|
||||
"contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Person, organisation, news, community, relay"],
|
||||
"created" => ["type" => "datetime", "comment" => ""],
|
||||
"comments" => ["type" => "mediumint unsigned", "comment" => "Number of comments"],
|
||||
|
@ -1335,7 +1335,7 @@ return [
|
|||
],
|
||||
"indexes" => [
|
||||
"PRIMARY" => ["uri-id"],
|
||||
"author-id" => ["author-id"],
|
||||
"owner-id" => ["owner-id"],
|
||||
"created" => ["created"],
|
||||
]
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue