apactorprofile.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * GNU social - a federating social network
  4. *
  5. * ActivityPubPlugin implementation for GNU Social
  6. *
  7. * LICENCE: This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * @category Plugin
  21. * @package GNUsocial
  22. * @author Daniel Supernault <danielsupernault@gmail.com>
  23. * @author Diogo Cordeiro <diogo@fc.up.pt>
  24. * @copyright 2018 Free Software Foundation http://fsf.org
  25. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  26. * @link https://www.gnu.org/software/social/
  27. */
  28. if (!defined ('GNUSOCIAL')) {
  29. exit (1);
  30. }
  31. /**
  32. * Actor's profile (Local users only)
  33. *
  34. * @category Plugin
  35. * @package GNUsocial
  36. * @author Daniel Supernault <danielsupernault@gmail.com>
  37. * @author Diogo Cordeiro <diogo@fc.up.pt>
  38. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  39. * @link http://www.gnu.org/software/social/
  40. */
  41. class apActorProfileAction extends ManagedAction
  42. {
  43. protected $needLogin = false;
  44. protected $canPost = true;
  45. /**
  46. * Handle the Actor Profile request
  47. *
  48. * @return void
  49. */
  50. protected function handle()
  51. {
  52. $nickname = $this->trimmed ('nickname');
  53. try {
  54. $user = User::getByNickname ($nickname);
  55. $profile = $user->getProfile ();
  56. }
  57. catch (Exception $e) {
  58. ActivityPubReturn::error ('Invalid username.', 404);
  59. }
  60. $res = Activitypub_profile::profile_to_array ($profile);
  61. ActivityPubReturn::answer ($res);
  62. }
  63. }