Activitypub_activityverb2.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 Diogo Cordeiro <diogo@fc.up.pt>
  23. * @copyright 2018 Free Software Foundation http://fsf.org
  24. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  25. * @link https://www.gnu.org/software/social/
  26. */
  27. if (!defined('GNUSOCIAL')) {
  28. exit(1);
  29. }
  30. /**
  31. * Utility class to hold a bunch of constant defining default verb types
  32. *
  33. * @category Plugin
  34. * @package GNUsocial
  35. * @author Diogo Cordeiro <diogo@fc.up.pt>
  36. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  37. * @link http://www.gnu.org/software/social/
  38. */
  39. class Activitypub_activityverb2 extends Managed_DataObject
  40. {
  41. const FULL_LIST =
  42. [
  43. 'Accept' => 'https://www.w3.org/ns/activitystreams#Accept',
  44. 'TentativeAccept' => 'https://www.w3.org/ns/activitystreams#TentativeAccept',
  45. 'Add' => 'https://www.w3.org/ns/activitystreams#Add',
  46. 'Arrive' => 'https://www.w3.org/ns/activitystreams#Arrive',
  47. 'Create' => 'https://www.w3.org/ns/activitystreams#Create',
  48. 'Delete' => 'https://www.w3.org/ns/activitystreams#Delete',
  49. 'Follow' => 'https://www.w3.org/ns/activitystreams#Follow',
  50. 'Ignore' => 'https://www.w3.org/ns/activitystreams#Ignore',
  51. 'Join' => 'https://www.w3.org/ns/activitystreams#Join',
  52. 'Leave' => 'https://www.w3.org/ns/activitystreams#Leave',
  53. 'Like' => 'https://www.w3.org/ns/activitystreams#Like',
  54. 'Offer' => 'https://www.w3.org/ns/activitystreams#Offer',
  55. 'Invite' => 'https://www.w3.org/ns/activitystreams#Invite',
  56. 'Reject' => 'https://www.w3.org/ns/activitystreams#Reject',
  57. 'TentativeReject' => 'https://www.w3.org/ns/activitystreams#TentativeReject',
  58. 'Remove' => 'https://www.w3.org/ns/activitystreams#Remove',
  59. 'Undo' => 'https://www.w3.org/ns/activitystreams#Undo',
  60. 'Update' => 'https://www.w3.org/ns/activitystreams#Update',
  61. 'View' => 'https://www.w3.org/ns/activitystreams#View',
  62. 'Listen' => 'https://www.w3.org/ns/activitystreams#Listen',
  63. 'Read' => 'https://www.w3.org/ns/activitystreams#Read',
  64. 'Move' => 'https://www.w3.org/ns/activitystreams#Move',
  65. 'Travel' => 'https://www.w3.org/ns/activitystreams#Travel',
  66. 'Announce' => 'https://www.w3.org/ns/activitystreams#Announce',
  67. 'Block' => 'https://www.w3.org/ns/activitystreams#Block',
  68. 'Flag' => 'https://www.w3.org/ns/activitystreams#Flag',
  69. 'Dislike' => 'https://www.w3.org/ns/activitystreams#Dislike',
  70. 'Question' => 'https://www.w3.org/ns/activitystreams#Question'
  71. ];
  72. const KNOWN =
  73. [
  74. 'Accept',
  75. 'Create',
  76. 'Delete',
  77. 'Follow',
  78. 'Like',
  79. 'Undo',
  80. 'Announce'
  81. ];
  82. /**
  83. * Converts canonical into verb.
  84. *
  85. * @author GNU Social
  86. * @param string $verb
  87. * @return string
  88. */
  89. public static function canonical($verb)
  90. {
  91. $ns = 'https://www.w3.org/ns/activitystreams#';
  92. if (substr($verb, 0, mb_strlen($ns)) == $ns) {
  93. return substr($verb, mb_strlen($ns));
  94. } else {
  95. return $verb;
  96. }
  97. }
  98. }