1
1
Fork 0

Formatting

This commit is contained in:
Michael 2021-11-24 23:06:28 +00:00
parent c4d52feea5
commit 242fd646d2
3 changed files with 21 additions and 21 deletions

View file

@ -42,31 +42,31 @@ class Seen extends BaseApi
{ {
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID(); $uid = BaseApi::getCurrentUserID();
if (DI::args()->getArgc() !== 4) { if (DI::args()->getArgc() !== 4) {
throw new BadRequestException('Invalid argument count'); throw new BadRequestException('Invalid argument count');
} }
$id = intval($_REQUEST['id'] ?? 0); $id = intval($_REQUEST['id'] ?? 0);
try { try {
$Notify = DI::notify()->selectOneById($id); $Notify = DI::notify()->selectOneById($id);
if ($Notify->uid !== $uid) { if ($Notify->uid !== $uid) {
throw new NotFoundException(); throw new NotFoundException();
} }
if ($Notify->uriId) { if ($Notify->uriId) {
DI::notification()->setAllSeenForUser($Notify->uid, ['target-uri-id' => $Notify->uriId]); DI::notification()->setAllSeenForUser($Notify->uid, ['target-uri-id' => $Notify->uriId]);
} }
$Notify->setSeen(); $Notify->setSeen();
DI::notify()->save($Notify); DI::notify()->save($Notify);
if ($Notify->otype === Notification\ObjectType::ITEM) { if ($Notify->otype === Notification\ObjectType::ITEM) {
$item = Post::selectFirstForUser($uid, [], ['id' => $Notify->iid, 'uid' => $uid]); $item = Post::selectFirstForUser($uid, [], ['id' => $Notify->iid, 'uid' => $uid]);
if (DBA::isResult($item)) { if (DBA::isResult($item)) {
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true'); $include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
// we found the item, return it to the user // we found the item, return it to the user
$ret = [DI::twitterStatus()->createFromUriId($item['uri-id'], $item['uid'], $include_entities)->toArray()]; $ret = [DI::twitterStatus()->createFromUriId($item['uri-id'], $item['uid'], $include_entities)->toArray()];
$data = ['status' => $ret]; $data = ['status' => $ret];
@ -74,7 +74,7 @@ class Seen extends BaseApi
} }
// the item can't be found, but we set the notification as seen, so we count this as a success // the item can't be found, but we set the notification as seen, so we count this as a success
} }
DI::apiResponse()->exit('statuses', ['result' => 'success'], $this->parameters['extension'] ?? null); DI::apiResponse()->exit('statuses', ['result' => 'success'], $this->parameters['extension'] ?? null);
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
throw new BadRequestException('Invalid argument', $e); throw new BadRequestException('Invalid argument', $e);

View file

@ -36,34 +36,34 @@ class UpdateProfile extends BaseApi
{ {
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID(); $uid = BaseApi::getCurrentUserID();
$api_user = DI::twitterUser()->createFromUserId($uid, true)->toArray(); $api_user = DI::twitterUser()->createFromUserId($uid, true)->toArray();
if (!empty($_POST['name'])) { if (!empty($_POST['name'])) {
DBA::update('profile', ['name' => $_POST['name']], ['uid' => $uid]); DBA::update('profile', ['name' => $_POST['name']], ['uid' => $uid]);
DBA::update('user', ['username' => $_POST['name']], ['uid' => $uid]); DBA::update('user', ['username' => $_POST['name']], ['uid' => $uid]);
Contact::update(['name' => $_POST['name']], ['uid' => $uid, 'self' => 1]); Contact::update(['name' => $_POST['name']], ['uid' => $uid, 'self' => 1]);
Contact::update(['name' => $_POST['name']], ['id' => $api_user['id']]); Contact::update(['name' => $_POST['name']], ['id' => $api_user['id']]);
} }
if (isset($_POST['description'])) { if (isset($_POST['description'])) {
DBA::update('profile', ['about' => $_POST['description']], ['uid' => $uid]); DBA::update('profile', ['about' => $_POST['description']], ['uid' => $uid]);
Contact::update(['about' => $_POST['description']], ['uid' => $uid, 'self' => 1]); Contact::update(['about' => $_POST['description']], ['uid' => $uid, 'self' => 1]);
Contact::update(['about' => $_POST['description']], ['id' => $api_user['id']]); Contact::update(['about' => $_POST['description']], ['id' => $api_user['id']]);
} }
Profile::publishUpdate($uid); Profile::publishUpdate($uid);
$skip_status = $_REQUEST['skip_status'] ?? false; $skip_status = $_REQUEST['skip_status'] ?? false;
$user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray(); $user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray();
// "verified" isn't used here in the standard // "verified" isn't used here in the standard
unset($user_info["verified"]); unset($user_info["verified"]);
// "uid" is only needed for some internal stuff, so remove it from here // "uid" is only needed for some internal stuff, so remove it from here
unset($user_info['uid']); unset($user_info['uid']);
DI::apiResponse()->exit('user', ['user' => $user_info], $this->parameters['extension'] ?? null); DI::apiResponse()->exit('user', ['user' => $user_info], $this->parameters['extension'] ?? null);
} }
} }

View file

@ -36,14 +36,14 @@ class VerifyCredentials extends BaseApi
{ {
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID(); $uid = BaseApi::getCurrentUserID();
$skip_status = $_REQUEST['skip_status'] ?? false; $skip_status = $_REQUEST['skip_status'] ?? false;
$user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray(); $user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray();
// "verified" isn't used here in the standard // "verified" isn't used here in the standard
unset($user_info["verified"]); unset($user_info["verified"]);
// "uid" is only needed for some internal stuff, so remove it from here // "uid" is only needed for some internal stuff, so remove it from here
unset($user_info['uid']); unset($user_info['uid']);