• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

decentraland / comms-message-sfu / 15462759206

05 Jun 2025 08:52AM UTC coverage: 88.415%. First build
15462759206

push

github

web-flow
feat: Skip messages from non members (#17)

* feat: Skip messages from non members

* feat: Test the new validation

55 of 69 branches covered (79.71%)

Branch coverage included in aggregate %.

5 of 7 new or added lines in 2 files covered. (71.43%)

235 of 259 relevant lines covered (90.73%)

8.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.17
/src/adapters/db.ts
1
import SQL from 'sql-template-strings'
4✔
2
import { AppComponents } from '../types'
3

4
export type IDatabaseComponent = {
5
  belongsToCommunity: (communityId: string, address: string) => Promise<boolean>
6
  getCommunityMembers: (
7
    communityId: string,
8
    options?: {
9
      include?: string[]
10
      exclude?: string[]
11
    }
12
  ) => Promise<string[]>
13
}
14

15
export async function createDBComponent(components: Pick<AppComponents, 'pg'>): Promise<IDatabaseComponent> {
4✔
16
  const { pg } = components
14✔
17

18
  const belongsToCommunity = async (communityId: string, address: string) => {
14✔
NEW
19
    const result = await pg.query(
×
20
      SQL`SELECT EXISTS(SELECT 1 FROM community_members WHERE community_id = ${communityId} AND member_address = ${address.toLowerCase()})`
21
    )
NEW
22
    return result.rows[0].exists ?? false
×
23
  }
24

25
  const getCommunityMembers = async (
14✔
26
    communityId: string,
27
    options?: {
28
      include?: string[]
29
      exclude?: string[]
30
    }
31
  ) => {
32
    const includeAddresses = options?.include?.map((address) => `'${address.toLowerCase()}'`)
12✔
33
    const excludeAddresses = options?.exclude?.map((address) => `'${address.toLowerCase()}'`)
12✔
34

35
    const query = SQL`
12✔
36
      SELECT LOWER(cm.member_address) as address FROM communities c
37
      LEFT JOIN community_members cm ON cm.community_id = c.id
38
      WHERE c.id = ${communityId} AND c.active = TRUE`
39

40
    if (includeAddresses) {
12✔
41
      query.append(` AND cm.member_address IN (${includeAddresses.join(',')})`)
4✔
42
    }
43

44
    if (excludeAddresses) {
12✔
45
      query.append(` AND cm.member_address NOT IN (${excludeAddresses.join(',')})`)
4✔
46
    }
47

48
    const result = await pg.query(query)
12✔
49
    return result.rows.map((row) => row.address)
18✔
50
  }
51

52
  return { belongsToCommunity, getCommunityMembers }
14✔
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc