Activitypub_activityverb2.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * ActivityPub implementation for GNU social
  18. *
  19. * @package GNUsocial
  20. * @author Diogo Cordeiro <diogo@fc.up.pt>
  21. * @copyright 2018-2019 Free Software Foundation, Inc http://www.fsf.org
  22. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  23. * @link http://www.gnu.org/software/social/
  24. */
  25. defined('GNUSOCIAL') || die();
  26. /**
  27. * Utility class to hold a bunch of constant defining default verb types
  28. *
  29. * @category Plugin
  30. * @package GNUsocial
  31. * @author Diogo Cordeiro <diogo@fc.up.pt>
  32. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  33. */
  34. class Activitypub_activityverb2 extends Managed_DataObject
  35. {
  36. const FULL_LIST =
  37. [
  38. 'Accept' => 'https://www.w3.org/ns/activitystreams#Accept',
  39. 'TentativeAccept' => 'https://www.w3.org/ns/activitystreams#TentativeAccept',
  40. 'Add' => 'https://www.w3.org/ns/activitystreams#Add',
  41. 'Arrive' => 'https://www.w3.org/ns/activitystreams#Arrive',
  42. 'Create' => 'https://www.w3.org/ns/activitystreams#Create',
  43. 'Delete' => 'https://www.w3.org/ns/activitystreams#Delete',
  44. 'Follow' => 'https://www.w3.org/ns/activitystreams#Follow',
  45. 'Ignore' => 'https://www.w3.org/ns/activitystreams#Ignore',
  46. 'Join' => 'https://www.w3.org/ns/activitystreams#Join',
  47. 'Leave' => 'https://www.w3.org/ns/activitystreams#Leave',
  48. 'Like' => 'https://www.w3.org/ns/activitystreams#Like',
  49. 'Offer' => 'https://www.w3.org/ns/activitystreams#Offer',
  50. 'Invite' => 'https://www.w3.org/ns/activitystreams#Invite',
  51. 'Reject' => 'https://www.w3.org/ns/activitystreams#Reject',
  52. 'TentativeReject' => 'https://www.w3.org/ns/activitystreams#TentativeReject',
  53. 'Remove' => 'https://www.w3.org/ns/activitystreams#Remove',
  54. 'Undo' => 'https://www.w3.org/ns/activitystreams#Undo',
  55. 'Update' => 'https://www.w3.org/ns/activitystreams#Update',
  56. 'View' => 'https://www.w3.org/ns/activitystreams#View',
  57. 'Listen' => 'https://www.w3.org/ns/activitystreams#Listen',
  58. 'Read' => 'https://www.w3.org/ns/activitystreams#Read',
  59. 'Move' => 'https://www.w3.org/ns/activitystreams#Move',
  60. 'Travel' => 'https://www.w3.org/ns/activitystreams#Travel',
  61. 'Announce' => 'https://www.w3.org/ns/activitystreams#Announce',
  62. 'Block' => 'https://www.w3.org/ns/activitystreams#Block',
  63. 'Flag' => 'https://www.w3.org/ns/activitystreams#Flag',
  64. 'Dislike' => 'https://www.w3.org/ns/activitystreams#Dislike',
  65. 'Question' => 'https://www.w3.org/ns/activitystreams#Question'
  66. ];
  67. const KNOWN =
  68. [
  69. 'Accept',
  70. 'Create',
  71. 'Delete',
  72. 'Follow',
  73. 'Like',
  74. 'Undo',
  75. 'Announce'
  76. ];
  77. /**
  78. * Converts canonical into verb.
  79. *
  80. * @author GNU social
  81. * @param string $verb
  82. * @return string
  83. */
  84. public static function canonical($verb)
  85. {
  86. $ns = 'https://www.w3.org/ns/activitystreams#';
  87. if (substr($verb, 0, mb_strlen($ns)) == $ns) {
  88. return substr($verb, mb_strlen($ns));
  89. } else {
  90. return $verb;
  91. }
  92. }
  93. }