perlsky is a Perl 5 implementation of an AT Protocol Personal Data Server.
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

Deduplicate misc API helpers

alice 8e481884 5d24fa63

+28 -26
+24 -26
lib/ATProto/PDS/API/Misc.pm
··· 126 126 my $did_doc = refresh_plc_did_doc($c->app->settings, $account->{did}); 127 127 $c->store->update_account($account->{did}, did_doc => $did_doc); 128 128 $account = $c->store->update_account($account->{did}, did_doc => $did_doc); 129 - $c->append_event( 130 - did => $account->{did}, 131 - type => 'identity', 132 - rev => $account->{repo_rev}, 133 - payload => { 134 - did => $account->{did}, 135 - handle => $account->{handle}, 136 - }, 137 - ); 129 + _append_identity_event($c, $account); 138 130 return {}; 139 131 }); 140 132 ··· 157 149 handle => $handle, 158 150 did_doc => $did_doc, 159 151 ); 160 - $c->append_event( 161 - did => $updated->{did}, 162 - type => 'identity', 163 - rev => $updated->{repo_rev}, 164 - payload => { 165 - did => $updated->{did}, 166 - handle => $updated->{handle}, 167 - }, 168 - ); 152 + _append_identity_event($c, $updated); 169 153 return {}; 170 154 }); 171 155 ··· 213 197 limit => $c->param('limit') // 50, 214 198 cursor => $c->param('cursor'), 215 199 ); 216 - return { 217 - (defined $page->{cursor} ? (cursor => $page->{cursor}) : ()), 218 - labels => [ map { _label_view($_) } @{ $page->{items} } ], 219 - }; 200 + return _label_page($page); 220 201 }); 221 202 222 203 $registry->register('com.atproto.temp.fetchLabels', sub ($c, $endpoint) { ··· 224 205 limit => $c->param('limit') // 50, 225 206 cursor => $c->param('cursor'), 226 207 ); 227 - return { 228 - (defined $page->{cursor} ? (cursor => $page->{cursor}) : ()), 229 - labels => [ map { _label_view($_) } @{ $page->{items} } ], 230 - }; 208 + return _label_page($page); 231 209 }); 232 210 233 211 $registry->register('com.atproto.label.subscribeLabels', sub ($c, $endpoint) { ··· 310 288 cts => iso8601($row->{created_at}), 311 289 (defined($row->{exp}) ? (exp => iso8601($row->{exp})) : ()), 312 290 (defined($row->{sig}) ? (sig => $row->{sig}) : ()), 291 + }; 292 + } 293 + 294 + sub _append_identity_event ($c, $account) { 295 + $c->append_event( 296 + did => $account->{did}, 297 + type => 'identity', 298 + rev => $account->{repo_rev}, 299 + payload => { 300 + did => $account->{did}, 301 + handle => $account->{handle}, 302 + }, 303 + ); 304 + return; 305 + } 306 + 307 + sub _label_page ($page) { 308 + return { 309 + (defined $page->{cursor} ? (cursor => $page->{cursor}) : ()), 310 + labels => [ map { _label_view($_) } @{ $page->{items} } ], 313 311 }; 314 312 } 315 313
+4
t/extended-api.t
··· 200 200 ))->status_is(200) 201 201 ->json_is('/labels/0/val', '!hide'); 202 202 203 + $t->get_ok('/xrpc/com.atproto.temp.fetchLabels?limit=10') 204 + ->status_is(200) 205 + ->json_is('/labels/0/val', '!hide'); 206 + 203 207 $t->post_ok('/xrpc/com.atproto.sync.requestCrawl' => json => { 204 208 hostname => 'relay.example.test', 205 209 })->status_is(200);