[🐴] Show if user can be messaged in new chat search (#4021)

* show if user can be messaged

* allow 2 lines in handle field due to new text

* cannot -> can't

* rework canBeMessaged logic and move to new file

---------

Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
Samuel Newman
2024-05-15 16:05:17 +01:00
committed by GitHub
parent 2121b5f86f
commit ed8922281a
5 changed files with 61 additions and 17 deletions
+18
View File
@@ -0,0 +1,18 @@
import {AppBskyActorDefs} from '@atproto/api'
export function canBeMessaged(profile: AppBskyActorDefs.ProfileView) {
switch (profile.associated?.chat?.allowIncoming) {
case 'none':
return false
case 'all':
return true
// if unset, treat as following
case 'following':
case undefined:
return Boolean(profile.viewer?.followedBy)
// any other values are invalid according to the lexicon, so
// let's treat as false to be safe
default:
return false
}
}