ed8922281a
* 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>
19 lines
510 B
TypeScript
19 lines
510 B
TypeScript
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
|
|
}
|
|
}
|