*/
function api_account_verify_credentials($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
unset($_REQUEST["user_id"]);
{
$a = DI::app();
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
-
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
{
$a = DI::app();
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
-
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
// convert $_POST array items to the form we use for web posts.
{
$a = DI::app();
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
-
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
if (empty($_FILES['media'])) {
*/
function api_search($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
if (preg_match('/^#(\w+)$/', $searchTerm, $matches) === 1 && isset($matches[1])) {
$searchTerm = $matches[1];
- $condition = ["`iid` > ? AND `name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))", $since_id, $searchTerm, local_user()];
+ $condition = ["`iid` > ? AND `name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))", $since_id, $searchTerm, BaseApi::getCurrentUserID()];
$tags = DBA::select('tag-search-view', ['uri-id'], $condition);
$uriids = [];
while ($tag = DBA::fetch($tags)) {
*/
function api_statuses_home_timeline($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
*/
function api_statuses_public_timeline($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
*/
function api_statuses_networkpublic_timeline($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
*/
function api_statuses_show($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
*/
function api_conversation_show($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
$a = DI::app();
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
-
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
// params
if (DBA::isResult($item) && !empty($item['body'])) {
if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::TWITTER])) {
- if (!Item::performActivity($id, 'announce', local_user())) {
+ if (!Item::performActivity($id, 'announce', BaseApi::getCurrentUserID())) {
throw new InternalServerErrorException();
}
*/
function api_statuses_destroy($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
-
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
// params
*/
function api_statuses_mentions($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
*/
function api_statuses_user_timeline($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
*/
function api_favorites_create_destroy($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
-
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
// for versioned api.
{
global $called_api;
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
*/
function api_lists_ownerships($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
// params
*/
function api_lists_statuses($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
*/
function api_direct_messages_new($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
-
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
- if (empty($uid)) {
- throw new ForbiddenException();
- }
if (empty($_POST["text"]) || empty($_POST["screen_name"]) && empty($_POST["user_id"])) {
return;
*/
function api_direct_messages_destroy($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
-
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
// params
*/
function api_friendships_destroy($type)
{
+ BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
- if ($uid === false) {
- throw new HTTPException\ForbiddenException();
- }
-
$owner = User::getOwnerDataById($uid);
if (!$owner) {
Logger::notice(API_LOG_PREFIX . 'No owner {uid} found', ['module' => 'api', 'action' => 'friendships_destroy', 'uid' => $uid]);
*/
function api_direct_messages_box($type, $box, $verbose)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
// params
*/
function api_fr_photos_list($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
+ BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
+
$r = DBA::toArray(DBA::p(
"SELECT `resource-id`, MAX(scale) AS `scale`, `album`, `filename`, `type`, MAX(`created`) AS `created`,
MAX(`edited`) AS `edited`, MAX(`desc`) AS `desc` FROM `photo`
WHERE `uid` = ? AND NOT `photo-type` IN (?, ?) GROUP BY `resource-id`, `album`, `filename`, `type`",
- local_user(), Photo::CONTACT_AVATAR, Photo::CONTACT_BANNER
+ BaseApi::getCurrentUserID(), Photo::CONTACT_AVATAR, Photo::CONTACT_BANNER
));
$typetoext = [
'image/jpeg' => 'jpg',
*/
function api_fr_photo_create_update($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
+ BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
+
// input params
$photo_id = $_REQUEST['photo_id'] ?? null;
$desc = $_REQUEST['desc'] ?? null;
*/
function api_fr_photo_detail($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
+ BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
+
if (empty($_REQUEST['photo_id'])) {
throw new BadRequestException("No photo id.");
}
*/
function api_account_update_profile_image($type)
{
- if (empty(BaseApi::getCurrentUserID())) {
- throw new ForbiddenException();
- }
+ BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
+
// input params
$profile_id = $_REQUEST['profile_id'] ?? 0;
// upload normal image (scales 0, 1, 2)
logger::info("photo upload: starting new photo upload");
- $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 0, Photo::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, BaseApi::getCurrentUserID(), $visitor, $resource_id, $filename, $album, 0, Photo::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
logger::notice("photo upload: image upload with scale 0 (original size) failed");
}
if ($width > 640 || $height > 640) {
$Image->scaleDown(640);
- $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 1, Photo::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, BaseApi::getCurrentUserID(), $visitor, $resource_id, $filename, $album, 1, Photo::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
logger::notice("photo upload: image upload with scale 1 (640x640) failed");
}
if ($width > 320 || $height > 320) {
$Image->scaleDown(320);
- $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 2, Photo::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, BaseApi::getCurrentUserID(), $visitor, $resource_id, $filename, $album, 2, Photo::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
logger::notice("photo upload: image upload with scale 2 (320x320) failed");
}
if ($width > 300 || $height > 300) {
$Image->scaleDown(300);
- $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 4, $phototype, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, BaseApi::getCurrentUserID(), $visitor, $resource_id, $filename, $album, 4, $phototype, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
logger::notice("photo upload: profile image upload with scale 4 (300x300) failed");
}
if ($width > 80 || $height > 80) {
$Image->scaleDown(80);
- $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 5, $phototype, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, BaseApi::getCurrentUserID(), $visitor, $resource_id, $filename, $album, 5, $phototype, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
logger::notice("photo upload: profile image upload with scale 5 (80x80) failed");
}
if ($width > 48 || $height > 48) {
$Image->scaleDown(48);
- $r = Photo::store($Image, local_user(), $visitor, $resource_id, $filename, $album, 6, $phototype, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
+ $r = Photo::store($Image, BaseApi::getCurrentUserID(), $visitor, $resource_id, $filename, $album, 6, $phototype, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) {
logger::notice("photo upload: profile image upload with scale 6 (48x48) failed");
}
FROM `photo` WHERE `uid` = ? AND `resource-id` = ? $scale_sql GROUP BY
`resource-id`, `created`, `edited`, `title`, `desc`, `album`, `filename`,
`type`, `height`, `width`, `datasize`, `profile`, `allow_cid`, `deny_cid`, `allow_gid`, `deny_gid`",
- local_user(),
+ BaseApi::getCurrentUserID(),
$photo_id
));