( permissions: Permissions, community: accounts, isBot: boolean = false )
| 71 | } |
| 72 | |
| 73 | export async function fetchCommon( |
| 74 | permissions: Permissions, |
| 75 | community: accounts, |
| 76 | isBot: boolean = false |
| 77 | ) { |
| 78 | const publicChannels = await ChannelsService.findPublic(community.id, isBot); |
| 79 | |
| 80 | const joinedChannels = !!permissions.user?.id |
| 81 | ? await ChannelsService.findJoined({ |
| 82 | accountId: community.id, |
| 83 | userId: permissions.user.id, |
| 84 | }) |
| 85 | : publicChannels; |
| 86 | |
| 87 | const privateChannels = !!permissions.user?.id |
| 88 | ? await ChannelsService.findPrivates({ |
| 89 | accountId: community.id, |
| 90 | userId: permissions.user.id, |
| 91 | }) |
| 92 | : []; |
| 93 | |
| 94 | const settings = serializeSettings(community); |
| 95 | const communities = !!permissions.auth?.id |
| 96 | ? await CommunityService.findByAuthId(permissions.auth.id) |
| 97 | : []; |
| 98 | |
| 99 | const currentCommunity = serializeAccount(community); |
| 100 | |
| 101 | const dmChannels = !!permissions.user?.id |
| 102 | ? await getDMs({ |
| 103 | accountId: currentCommunity.id, |
| 104 | userId: permissions.user.id, |
| 105 | }) |
| 106 | : []; |
| 107 | |
| 108 | return { |
| 109 | currentCommunity, |
| 110 | publicChannels: publicChannels.map(serializeChannel), |
| 111 | joinedChannels: joinedChannels.map(serializeChannel), |
| 112 | privateChannels: privateChannels.map(serializeChannel), |
| 113 | communities, |
| 114 | settings, |
| 115 | dmChannels: dmChannels.map(serializeChannel), |
| 116 | }; |
| 117 | } |
| 118 | |
| 119 | export function allowAccess( |
| 120 | permissions: Permissions |
no test coverage detected