Followers API reference
Follow requests, acceptance and removal between users. The follow graph is visible only to its owner and their accepted followers. See Sharing, privacy and followers.
Service
Application logic for follower relationships.
The privacy-aware read surface (whether a requester may view a target's follower / following graph) and the follow / accept / unfollow writes. Access decisions live here, not in the router, so the same rule applies however this module is reached.
A user's follow graph is visible only to the user and their accepted followers. Endurain has no public-profile concept: profiles are never public, and only individual activities can be shared (via server-level public links), so no "public" tier applies to the follow graph.
This is the module's own application layer. What other modules may consume
lives in :mod:modules.followers.integration_service.
accept_follow_request
accept_follow_request(requester_user_id, follower_id, db)
Accept a pending follow request and publish follower.accepted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requester_user_id
|
UUID
|
The authenticated user accepting the request. |
required |
follower_id
|
UUID
|
The user whose pending request is being accepted. |
required |
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
FollowRelationshipRead
|
The accepted relationship, read back after the flush. |
Raises:
| Type | Description |
|---|---|
ConflictError
|
When the requester already follows the maximum number of users. |
NotFoundError
|
When no pending request from that user exists. |
Source code in backend/app/modules/followers/service.py
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
block_user
block_user(blocker_id, blocked_id, db)
Block a user: end every follow between the two and refuse the blocked user's future requests.
The answer is the same for a user that does not exist, so the route cannot be used to look users up. Nothing tells the blocked user: only a pending request is taken back, as when it is withdrawn. Blocking again changes nothing and writes no audit row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blocker_id
|
UUID
|
The user who blocks. |
required |
blocked_id
|
UUID
|
The user to block; must differ from the blocker (the route checks it). |
required |
db
|
Session
|
Database session. |
required |
Source code in backend/app/modules/followers/service.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
delete_relationship
delete_relationship(followee_id, follower_id, requester_user_id, db)
Delete a follow relationship on behalf of either party.
One operation serves unfollow and remove-follower: the row is the same and the direction is explicit in the arguments, so the only difference is which of the two parties asked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
followee_id
|
UUID
|
The user being followed. |
required |
follower_id
|
UUID
|
The user doing the following. |
required |
requester_user_id
|
UUID
|
The authenticated caller, who must be one of the two. |
required |
db
|
Session
|
Database session. |
required |
Publishes follower.request_removed when the deleted row was still a pending request, records a
decline when the followee removed it, and stages a followers.follow.remove audit row when it was
an accepted relationship.
Raises:
| Type | Description |
|---|---|
AccessConcealedError
|
When the caller is not part of the relationship; answered as a missing relationship so it does not confirm one exists. |
Source code in backend/app/modules/followers/service.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
follow_user
follow_user(requester_user_id, target_user_id, db)
Create a follow request and publish follower.requested.
The CRUD row write is the source of truth; the notification is produced by the
follower.requested subscriber reacting to the published event, so the
request succeeds even if notification delivery later fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requester_user_id
|
UUID
|
The authenticated user requesting to follow. |
required |
target_user_id
|
UUID
|
The user to follow. |
required |
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
FollowRelationshipRead
|
The newly created follow relationship as a DTO. |
Raises:
| Type | Description |
|---|---|
InvalidInputError
|
If the requester targets themselves. |
NotFoundError
|
If the target user does not exist, is inactive or awaits approval, or has blocked the requester. The answer is the same for all four, so a follow reveals nothing about hidden accounts or blocks. |
TooManyRequestsError
|
If the target declined a request from the requester less than
:data: |
ConflictError
|
If the requester blocked the target, the relationship already exists or the target already has the maximum pending requests. |
Source code in backend/app/modules/followers/service.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | |
get_profile_follow_counts
get_profile_follow_counts(target_user_id, requester_user_id, db)
Return accepted network counts, or None when the viewer cannot see the network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_user_id
|
UUID
|
The profile owner whose network to count. |
required |
requester_user_id
|
UUID
|
The authenticated viewer. |
required |
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
ProfileFollowCounts | None
|
Both accepted relationship counts, or None when the network is private to this viewer. |
Source code in backend/app/modules/followers/service.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
get_user_relationship
get_user_relationship(other_user_id, requester_user_id, db)
Return the authenticated user's relationship with another user (both directions).
Only ever reports relationships the requester is part of — their outgoing
follow of other_user_id and other_user_id's incoming follow of them —
so there is no way to probe arbitrary pairs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other_user_id
|
UUID
|
The other user in the relationship. |
required |
requester_user_id
|
UUID
|
The authenticated requester. |
required |
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
RelationshipRead
|
The requester's outgoing and incoming follow relationships with the other |
RelationshipRead
|
user (either may be None), and whether the requester blocked the other user. |
Source code in backend/app/modules/followers/service.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
list_blocked_users
list_blocked_users(blocker_id, db, *, page_number=1, num_records=core_pagination.DEFAULT_NUM_RECORDS)
Return one page of the users the caller blocked, newest block first.
A blocked user who is inactive or awaiting approval has no public profile, so the list leaves them out
and total does not count them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blocker_id
|
UUID
|
The user who blocked. |
required |
db
|
Session
|
Database session. |
required |
page_number
|
int
|
1-based page number. |
1
|
num_records
|
int
|
Page size. |
DEFAULT_NUM_RECORDS
|
Returns:
| Type | Description |
|---|---|
UserPublicPage
|
The page of public profiles. |
Source code in backend/app/modules/followers/service.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | |
list_followers
list_followers(target_user_id, requester_user_id, db, *, page_number=1, num_records=core_pagination.DEFAULT_NUM_RECORDS, accepted_only=False)
Return one page of the target's followers with the matching total.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_user_id
|
UUID
|
The user whose followers to list. |
required |
requester_user_id
|
UUID
|
The authenticated requester. |
required |
db
|
Session
|
Database session. |
required |
page_number
|
int
|
1-based page number. |
1
|
num_records
|
int
|
Page size. |
DEFAULT_NUM_RECORDS
|
accepted_only
|
bool
|
Exclude pending follow requests when True. |
False
|
Returns:
| Type | Description |
|---|---|
FollowRelationshipPage
|
The page envelope. |
FollowRelationshipPage
|
filter, not just this page. |
Raises:
| Type | Description |
|---|---|
AccessConcealedError
|
When the requester may not view this network; answered like a missing user. |
Source code in backend/app/modules/followers/service.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
list_following
list_following(target_user_id, requester_user_id, db, *, page_number=1, num_records=core_pagination.DEFAULT_NUM_RECORDS, accepted_only=False)
Return one page of who the target follows with the matching total.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_user_id
|
UUID
|
The user whose following list to return. |
required |
requester_user_id
|
UUID
|
The authenticated requester. |
required |
db
|
Session
|
Database session. |
required |
page_number
|
int
|
1-based page number. |
1
|
num_records
|
int
|
Page size. |
DEFAULT_NUM_RECORDS
|
accepted_only
|
bool
|
Exclude pending follow requests when True. |
False
|
Returns:
| Type | Description |
|---|---|
FollowRelationshipPage
|
The page envelope. |
FollowRelationshipPage
|
filter, not just this page. |
Raises:
| Type | Description |
|---|---|
AccessConcealedError
|
When the requester may not view this network; answered like a missing user. |
Source code in backend/app/modules/followers/service.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
list_pending_requests
list_pending_requests(requester_user_id, db, *, page_number=1, num_records=core_pagination.DEFAULT_NUM_RECORDS)
Return one page of follow requests awaiting the caller's decision.
Always scoped to the caller: a pending request is private to the two parties,
so there is no target_user_id to pass and therefore nothing to probe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requester_user_id
|
UUID
|
The authenticated caller. |
required |
db
|
Session
|
Database session. |
required |
page_number
|
int
|
1-based page number. |
1
|
num_records
|
int
|
Page size. |
DEFAULT_NUM_RECORDS
|
Returns:
| Type | Description |
|---|---|
FollowRelationshipPage
|
The page envelope, with the profile of each requester. |
Source code in backend/app/modules/followers/service.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
reject_follow_request
reject_follow_request(requester_user_id, follower_id, db)
Decline a pending follow request addressed to the caller and publish follower.request_removed.
Records the decline, so the requester cannot ask the caller again for
:data:~modules.followers.constants.FOLLOW_REQUEST_COOLDOWN.
Distinct from :func:delete_relationship, which severs an already-accepted
relationship. Both delete the same row, but only one of them is a decision
the requester never had granted — so this one is scoped to PENDING, and
an accepted follower is removed through the relationship route instead of
silently through here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requester_user_id
|
UUID
|
The authenticated user declining the request. |
required |
follower_id
|
UUID
|
The user whose pending request is declined. |
required |
db
|
Session
|
Database session. |
required |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
When no pending request from that user exists. |
Source code in backend/app/modules/followers/service.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
unblock_user
unblock_user(blocker_id, blocked_id, db)
Remove a block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blocker_id
|
UUID
|
The user who blocked. |
required |
blocked_id
|
UUID
|
The user to unblock. |
required |
db
|
Session
|
Database session. |
required |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
When the user has not blocked that user. |
Source code in backend/app/modules/followers/service.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | |
Schemas
Pydantic schemas for follower relationships.
FollowRelationshipPage
Bases: Page[FollowRelationshipRead]
One page of follow relationships, in the envelope the activities lists use.
Attributes:
| Name | Type | Description |
|---|---|---|
users |
dict[UUID, UserPublicRead]
|
The public profile of the user on the other side of each row (the follower in a
followers list, the followee in a following list, the requester among pending requests),
keyed by user ID. It is the projection |
Source code in backend/app/modules/followers/schema.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
FollowRelationshipRead
Bases: BaseModel
Serialized representation of a follow relationship.
Attributes:
| Name | Type | Description |
|---|---|---|
follower_id |
UUID
|
The user who follows (the requester). |
followee_id |
UUID
|
The user being followed. |
status |
FollowStatus
|
Whether the request is pending or accepted. |
Source code in backend/app/modules/followers/schema.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
RelationshipRead
Bases: BaseModel
The authenticated user's relationship with another user, both directions.
Attributes:
| Name | Type | Description |
|---|---|---|
outgoing |
FollowRelationshipRead | None
|
The authenticated user's follow of the other user, if any. |
incoming |
FollowRelationshipRead | None
|
The other user's follow of the authenticated user, if any. |
is_blocked |
bool
|
Whether the authenticated user has blocked the other user. |
Source code in backend/app/modules/followers/schema.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
Events
Domain event channels owned by the followers module.
Channel names (event_type values) are owned by the publishing domain, not the
platform substrate. The follow service publishes the facts below; the follower
notification subscriber reacts by subscribing to the same constants, so producer
and subscriber cannot drift on the string. Convention: <domain>.<fact>, past
tense.
FollowerAcceptedPayload
Bases: VersionedPayload
Validated payload for the follower.accepted event.
Attributes:
| Name | Type | Description |
|---|---|---|
accepter_user_id |
UUID
|
The user who accepted the request. |
requester_user_id |
UUID
|
The original requester (who is notified). |
Source code in backend/app/modules/followers/events.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
FollowerRequestRemovedPayload
Bases: VersionedPayload
Validated payload for the follower.request_removed event.
Attributes:
| Name | Type | Description |
|---|---|---|
requester_user_id |
UUID
|
The user whose follow request was removed. |
target_user_id |
UUID
|
The user the request was addressed to (who owns the notification). |
Source code in backend/app/modules/followers/events.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
FollowerRequestedPayload
Bases: VersionedPayload
Validated payload for the follower.requested event.
Subscribers validate against this schema so a malformed payload raises at the boundary — with the offending fields named — instead of being silently dropped by ad-hoc type checks.
Attributes:
| Name | Type | Description |
|---|---|---|
requester_user_id |
UUID
|
The user who requested to follow. |
target_user_id |
UUID
|
The user being followed (who is notified). |
Source code in backend/app/modules/followers/events.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |