toddsundsted / ktistec

Single user ActivityPub (https://www.w3.org/TR/activitypub/) server.
GNU Affero General Public License v3.0
359 stars 20 forks source link

Feature Request: Search function in followers and following #32

Open vrthra opened 1 year ago

vrthra commented 1 year ago

As my network is growing, it is becoming a bit harder to keep track of specific people, and their posts. It would be nice to have a search function in the Followers and Following to check if I am following someone.

toddsundsted commented 1 year ago

as a work-around, you can Search for a user by their fediverse address and the result page will tell you if you follow them or not (based on the buttons that are present).

vrthra commented 1 year ago

Thanks, that helps.

vrthra commented 1 year ago

At present, I am finding that I remember the name of the person I am following but not necessarily their fediverse home server, (sometimes only a part of it). The search function expects the full address. With the pagination in the followers and following, it has become really hard to check for people.

vrthra commented 1 year ago

Is the following a reasonable query to get all the people I follow?

SELECT DISTINCT iri, username, name, summary
FROM actors AS a, relationships AS r
WHERE a.iri = r.to_iri
    AND r.type = 'Relationship::Social::Follow'
    AND a.deleted_at IS NULL
    AND a.blocked_at IS NULL
    AND a.id NOT IN (
                SELECT a.id
                  FROM actors AS a, relationships AS r
                 WHERE a.iri = r.to_iri
                   AND r.type = 'Relationship::Social::Follow'
                   AND a.deleted_at IS NULL
                   AND a.blocked_at IS NULL
                   AND r.from_iri = 1
             )
toddsundsted commented 1 year ago

@vrthra i would use the following:

SELECT DISTINCT iri, username, name, summary
  FROM actors AS a, relationships AS r
 WHERE a.iri = r.to_iri
   AND r.from_iri = 'https://epiktistes.com/actors/toddsundsted' -- replace with https://gopinath.org/actors/rahul
   AND r.type = 'Relationship::Social::Follow'
   AND a.deleted_at IS NULL
   AND a.blocked_at IS NULL
ORDER BY a.id

it avoids the nested query and filters your account out of the results.

there's code to this effect already in the actor class (in actor.cr) if you are looking for a way to access this in application.

vrthra commented 1 year ago

Thank you @toddsundsted much appreciated!

toddsundsted commented 1 year ago

np!

vrthra commented 1 year ago

Noting here that adding say size=1000 in the URL helps very much here. E.g. http://gopinath.org/actors/rahul/following?size=1000