MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / resolveOwnerMember

Function resolveOwnerMember

packages/core/src/query/contact-queries.ts:70–90  ·  view source on GitHub ↗
(db: DatabaseAdapter)

Source from the content-addressed store, hash-verified

68}
69
70export function resolveOwnerMember(db: DatabaseAdapter): ContactMemberRef | null {
71 const meta = db.prepare('SELECT owner_id FROM meta LIMIT 1').get() as { owner_id: string | null } | undefined
72 if (!isValidContactPlatformId(meta?.owner_id)) return null
73 const aliasesSelect = hasColumn(db, 'member', 'aliases') ? 'aliases' : 'NULL as aliases'
74
75 const row = db
76 .prepare(
77 `SELECT
78 id,
79 platform_id as platformId,
80 COALESCE(group_nickname, account_name, platform_id) as name,
81 ${aliasesSelect},
82 avatar
83 FROM member m
84 WHERE platform_id = ? AND ${nonSystemContactMemberCondition(db, 'm')}
85 LIMIT 1`
86 )
87 .get(meta.owner_id) as ContactMemberRow | undefined
88
89 return row ? mapContactMemberRow(row) : null
90}
91
92export function getNonSystemMembersForContacts(db: DatabaseAdapter): ContactMemberRef[] {
93 const aliasesSelect = hasColumn(db, 'member', 'aliases') ? 'aliases' : 'NULL as aliases'

Callers 4

computeSessionFactsFunction · 0.90
computeSessionFactsFunction · 0.90

Calls 6

hasColumnFunction · 0.90
isValidContactPlatformIdFunction · 0.85
mapContactMemberRowFunction · 0.85
getMethod · 0.65
prepareMethod · 0.65

Tested by

no test coverage detected