MCPcopy Create free account
hub / github.com/aptabase/aptabase / HasReadAccessToApp

Method HasReadAccessToApp

src/Features/Stats/StatsQueries.cs:9–28  ·  view source on GitHub ↗
(this IDbContext db, string appId, UserIdentity user, CancellationToken cancellationToken)

Source from the content-addressed store, hash-verified

7public static class StatsQueries
8{
9 public static async Task<bool> HasReadAccessToApp(this IDbContext db, string appId, UserIdentity user, CancellationToken cancellationToken)
10 {
11 var cmd = new CommandDefinition(
12 @"SELECT a.id
13 FROM apps a
14 LEFT JOIN app_shares s
15 ON s.app_id = a.id
16 LEFT JOIN users u
17 ON u.id = a.owner_id
18 WHERE a.id = @appId
19 AND (a.owner_id = @userId OR s.email = @userEmail)
20 AND u.lock_reason IS NULL
21 LIMIT 1",
22 new { appId, userId = user.Id, userEmail = user.Email },
23 cancellationToken: cancellationToken
24 );
25
26 var id = await db.Connection.ExecuteScalarAsync<string>(cmd);
27 return id == appId;
28 }
29}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected