Set item permissions on reshare

This commit is contained in:
Michael 2021-11-29 04:38:58 +00:00
parent 71f7679204
commit 0440765849
2 changed files with 17 additions and 0 deletions

View file

@ -27,6 +27,7 @@ use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Network\HTTPException\ForbiddenException;
@ -80,6 +81,21 @@ class Retweet extends BaseApi
'app' => $request['source'] ?? '',
];
$owner = User::getOwnerDataById($uid);
$item['allow_cid'] = $owner['allow_cid'];
$item['allow_gid'] = $owner['allow_gid'];
$item['deny_cid'] = $owner['deny_cid'];
$item['deny_gid'] = $owner['deny_gid'];
if (!empty($item['allow_cid'] . $item['allow_gid'] . $item['deny_cid'] . $item['deny_gid'])) {
$item['private'] = Item::PRIVATE;
} elseif (DI::pConfig()->get($uid, 'system', 'unlisted')) {
$item['private'] = Item::UNLISTED;
} else {
$item['private'] = Item::PUBLIC;
}
if (empty($item['app']) && !empty(self::getCurrentApplication()['name'])) {
$item['app'] = self::getCurrentApplication()['name'];
}

View file

@ -184,6 +184,7 @@ class Update extends BaseApi
// output the post that we just posted.
$status_info = DI::twitterStatus()->createFromUriId($item['uri-id'], $uid, $request['include_entities'])->toArray();
DI::apiResponse()->exit('status', ['status' => $status_info], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
return;
}
}
DI::mstdnError()->InternalError();