Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix duplicate notice on 'unlike', and fix 'unlike' related problems. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
814af2129afef76777b1e708e6952c8a |
User & Date: | tak4@mx.bibi.moe 2023-09-03 10:18:21 |
Context
2023-09-04
| ||
15:03 | Merge branch 'main' of tak4/gnusocial-jp into main check-in: e72f9e9600 user: gogitservice@gmail.com tags: trunk | |
2023-09-03
| ||
10:18 | Fix duplicate notice on 'unlike', and fix 'unlike' related problems. check-in: 814af2129a user: tak4@mx.bibi.moe tags: trunk | |
2023-08-21
| ||
14:31 | v2.0.2 check-in: 6b99252bf8 user: develop@senooken.jp tags: trunk, v2.0.2 | |
Changes
Changes to plugins/ActivityPub/ActivityPubPlugin.php.
︙ | ︙ | |||
135 136 137 138 139 140 141 | throw new Exception("A notice can't be created without an actor."); } if (parse_url($acclaimed_actor_profile->getUri(), PHP_URL_HOST) == parse_url($object['id'], PHP_URL_HOST)) { try { // Keep conversation tree return Notice::getByUri($object['id']); } catch (Exception $e) { | | | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | throw new Exception("A notice can't be created without an actor."); } if (parse_url($acclaimed_actor_profile->getUri(), PHP_URL_HOST) == parse_url($object['id'], PHP_URL_HOST)) { try { // Keep conversation tree return Notice::getByUri($object['id']); } catch (Exception $e) { common_debug('ActivityPubPlugin Notice Grabber: failed to find object-id: ' . $object['id']); } return Activitypub_notice::create_notice($object, $acclaimed_actor_profile); } else { throw new Exception("The acclaimed actor didn't create this note."); } } else { throw new Exception("Invalid Note Object. Maybe it's a Tombstone?"); |
︙ | ︙ |
Changes to plugins/ActivityPub/lib/inbox_handler.php.
︙ | ︙ | |||
387 388 389 390 391 392 393 | * @throws AlreadyFulfilledException * @throws ServerException * @throws Exception * @author Diogo Cordeiro <diogo@fc.up.pt> */ private function handle_undo_like() { | > > | | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | * @throws AlreadyFulfilledException * @throws ServerException * @throws Exception * @author Diogo Cordeiro <diogo@fc.up.pt> */ private function handle_undo_like() { $object = $this->activity['object']; $notice_url = $object['object']; $notice = ActivityPubPlugin::grab_notice_from_url($notice_url); Fave::removeEntry($this->actor, $notice); } /** * Handles a Announce Activity received by our inbox. * * @throws Exception |
︙ | ︙ |
Changes to plugins/ActivityPub/lib/models/Activitypub_like.php.
︙ | ︙ | |||
42 43 44 45 46 47 48 49 50 51 52 53 | * @param string $actor Actor URI * @param Notice $notice Notice URI * @return array pretty array to be used in a response * @author Diogo Cordeiro <diogo@fc.up.pt> */ public static function like_to_array(string $actor, Notice $notice): array { $res = [ '@context' => 'https://www.w3.org/ns/activitystreams', 'id' => Activitypub_notice::getUri($notice), 'type' => 'Like', 'actor' => $actor, | > > > > > > | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | * @param string $actor Actor URI * @param Notice $notice Notice URI * @return array pretty array to be used in a response * @author Diogo Cordeiro <diogo@fc.up.pt> */ public static function like_to_array(string $actor, Notice $notice): array { if ($notice->hasParent() && Notice::getByID($notice->reply_to)) { $object = Activitypub_notice::getUri($notice->getParent()); } else { // When unlike. $object = Activitypub_notice::getUri($notice); } $res = [ '@context' => 'https://www.w3.org/ns/activitystreams', 'id' => Activitypub_notice::getUri($notice), 'type' => 'Like', 'actor' => $actor, 'object' => $object, ]; return $res; } /** * Save a favorite record. * |
︙ | ︙ |
Changes to plugins/ActivityPub/lib/models/Activitypub_notice.php.
︙ | ︙ | |||
145 146 147 148 149 150 151 152 153 154 155 156 157 158 | * @author Diogo Cordeiro <diogo@fc.up.pt> */ public static function create_notice(array $object, Profile $actor_profile, bool $directMessage = false): Notice { $id = $object['id']; // int $url = isset($object['url']) ? $object['url'] : $id; // string $content = $object['content']; // string // possible keys: ['inReplyTo', 'latitude', 'longitude'] $settings = []; if (isset($object['inReplyTo'])) { $settings['inReplyTo'] = $object['inReplyTo']; } if (isset($object['latitude'])) { | > > > > > > | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | * @author Diogo Cordeiro <diogo@fc.up.pt> */ public static function create_notice(array $object, Profile $actor_profile, bool $directMessage = false): Notice { $id = $object['id']; // int $url = isset($object['url']) ? $object['url'] : $id; // string $content = $object['content']; // string // Avoid duplication if (is_numeric($id) && Notice::getByID((int)$id)) { common_debug('create_notice: not found $id' . $id); return null; } // possible keys: ['inReplyTo', 'latitude', 'longitude'] $settings = []; if (isset($object['inReplyTo'])) { $settings['inReplyTo'] = $object['inReplyTo']; } if (isset($object['latitude'])) { |
︙ | ︙ |