mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at new-image-api 27 lines 826 B view raw
1import {AppBskyActorDefs} from '@atproto/api' 2 3export function canBeMessaged(profile: AppBskyActorDefs.ProfileView) { 4 switch (profile.associated?.chat?.allowIncoming) { 5 case 'none': 6 return false 7 case 'all': 8 return true 9 // if unset, treat as following 10 case 'following': 11 case undefined: 12 return Boolean(profile.viewer?.followedBy) 13 // any other values are invalid according to the lexicon, so 14 // let's treat as false to be safe 15 default: 16 return false 17 } 18} 19 20export function localDateString(date: Date) { 21 // can't use toISOString because it should be in local time 22 const mm = date.getMonth() 23 const dd = date.getDate() 24 const yyyy = date.getFullYear() 25 // not padding with 0s because it's not necessary, it's just used for comparison 26 return `${yyyy}-${mm}-${dd}` 27}