@@ -12,7 +12,6 @@ import (
1212 "github.com/manchtools/power-manage/server/internal/actionparams"
1313 "github.com/manchtools/power-manage/server/internal/ca"
1414 "github.com/manchtools/power-manage/server/internal/store"
15- db "github.com/manchtools/power-manage/server/internal/store/generated"
1615)
1716
1817// SystemActionManager creates and maintains system-managed actions
@@ -54,7 +53,7 @@ func NewSystemActionManager(st *store.Store, signer ca.ActionSigner, logger *slo
5453// SyncAllUsersSystemActions ensures all users have correct system actions.
5554// Called at startup and after global settings changes. Idempotent.
5655func (m * SystemActionManager ) SyncAllUsersSystemActions (ctx context.Context ) error {
57- users , err := m .store .Queries ().ListAllNonDeletedUsers (ctx )
56+ users , err := m .store .Repos ().User . ListAllNonDeleted (ctx )
5857 if err != nil {
5958 return fmt .Errorf ("list users: %w" , err )
6059 }
@@ -145,7 +144,7 @@ func (m *SystemActionManager) StartReconciliation(ctx context.Context, interval,
145144// Disabled users get a disabled flag in their USER action params.
146145// Idempotent and safe to call after any user mutation.
147146func (m * SystemActionManager ) SyncUserSystemActions (ctx context.Context , userID string ) error {
148- user , err := m .store .Queries ().GetUserByID (ctx , userID )
147+ user , err := m .store .Repos ().User . Get (ctx , userID )
149148 if err != nil {
150149 return fmt .Errorf ("get user: %w" , err )
151150 }
@@ -199,7 +198,7 @@ func (m *SystemActionManager) SyncUserSystemActions(ctx context.Context, userID
199198 // If the permission query fails, we skip the TTY block entirely
200199 // and leave the existing state untouched — a transient DB error
201200 // must NOT trigger a cleanup that deletes a working TTY account.
202- permissions , err := m .store .Queries ().GetUserPermissionsWithGroups (ctx , userID )
201+ permissions , err := m .store .Repos ().User . Permissions (ctx , userID )
203202 if err != nil {
204203 m .logger .Error ("failed to resolve user permissions for tty action sync; leaving TTY state unchanged" ,
205204 "user_id" , userID , "error" , err )
@@ -227,7 +226,7 @@ func (m *SystemActionManager) SyncUserSystemActions(ctx context.Context, userID
227226
228227// CleanupDeletedUserActions removes all system actions for a deleted user.
229228// Must be called with the user projection loaded BEFORE the delete event.
230- func (m * SystemActionManager ) CleanupDeletedUserActions (ctx context.Context , user db. UsersProjection ) error {
229+ func (m * SystemActionManager ) CleanupDeletedUserActions (ctx context.Context , user store. User ) error {
231230 if user .SystemUserActionID != "" {
232231 if err := m .actions .DeleteAction (ctx , user .SystemUserActionID ); err != nil {
233232 m .logger .Error ("failed to delete system user action" , "action_id" , user .SystemUserActionID , "error" , err )
@@ -255,7 +254,7 @@ func (m *SystemActionManager) CleanupDeletedUserActions(ctx context.Context, use
255254 return nil
256255}
257256
258- func (m * SystemActionManager ) syncUserProvisionAction (ctx context.Context , user db. UsersProjection , sshKeys []string ) error {
257+ func (m * SystemActionManager ) syncUserProvisionAction (ctx context.Context , user store. User , sshKeys []string ) error {
259258 comment := user .DisplayName
260259 if comment == "" {
261260 comment = user .Email
@@ -268,7 +267,7 @@ func (m *SystemActionManager) syncUserProvisionAction(ctx context.Context, user
268267 // recur here.
269268 params := & pm.UserParams {
270269 Username : user .LinuxUsername ,
271- Uid : user .LinuxUid ,
270+ Uid : user .LinuxUID ,
272271 CreateHome : true ,
273272 Comment : comment ,
274273 Disabled : user .Disabled ,
@@ -316,7 +315,7 @@ func (m *SystemActionManager) syncUserProvisionAction(ctx context.Context, user
316315 return nil
317316}
318317
319- func (m * SystemActionManager ) syncSshAccessAction (ctx context.Context , user db. UsersProjection ) error {
318+ func (m * SystemActionManager ) syncSshAccessAction (ctx context.Context , user store. User ) error {
320319 // Typed *pm.SshParams — same rationale as syncUserProvisionAction.
321320 params := & pm.SshParams {
322321 Users : []string {user .LinuxUsername },
@@ -363,7 +362,7 @@ func (m *SystemActionManager) syncSshAccessAction(ctx context.Context, user db.U
363362 return nil
364363}
365364
366- func (m * SystemActionManager ) cleanupUserAction (ctx context.Context , user db. UsersProjection ) error {
365+ func (m * SystemActionManager ) cleanupUserAction (ctx context.Context , user store. User ) error {
367366 if user .SystemUserActionID == "" {
368367 return nil
369368 }
@@ -377,7 +376,7 @@ func (m *SystemActionManager) cleanupUserAction(ctx context.Context, user db.Use
377376 return nil
378377}
379378
380- func (m * SystemActionManager ) cleanupSshAction (ctx context.Context , user db. UsersProjection ) error {
379+ func (m * SystemActionManager ) cleanupSshAction (ctx context.Context , user store. User ) error {
381380 if user .SystemSshActionID == "" {
382381 return nil
383382 }
@@ -402,7 +401,7 @@ func (m *SystemActionManager) cleanupSshAction(ctx context.Context, user db.User
402401// The action uses nologin as the shell (the agent temporarily
403402// activates it during a session), no home directory, and the
404403// deterministic UID from the SDK's TTYUID helper.
405- func (m * SystemActionManager ) syncTtyUserAction (ctx context.Context , user db. UsersProjection ) error {
404+ func (m * SystemActionManager ) syncTtyUserAction (ctx context.Context , user store. User ) error {
406405 // Typed *pm.UserParams so the Go compiler rejects field-name
407406 // typos. The previous map[string]any form accepted "system": true
408407 // as a sibling of real fields — protojson silently dropped it on
@@ -467,9 +466,9 @@ func (m *SystemActionManager) syncTtyUserAction(ctx context.Context, user db.Use
467466 return nil
468467}
469468
470- func systemTtyUserParams (user db. UsersProjection ) * pm.UserParams {
469+ func systemTtyUserParams (user store. User ) * pm.UserParams {
471470 ttyUsername := "pm-tty-" + user .LinuxUsername
472- ttyUID := int32 (int (user .LinuxUid ) + 100000 ) // terminal.DefaultUIDOffset
471+ ttyUID := int32 (int (user .LinuxUID ) + 100000 ) // terminal.DefaultUIDOffset
473472
474473 return & pm.UserParams {
475474 Username : ttyUsername ,
@@ -482,7 +481,7 @@ func systemTtyUserParams(user db.UsersProjection) *pm.UserParams {
482481 }
483482}
484483
485- func (m * SystemActionManager ) cleanupTtyAction (ctx context.Context , user db. UsersProjection ) error {
484+ func (m * SystemActionManager ) cleanupTtyAction (ctx context.Context , user store. User ) error {
486485 if user .SystemTtyActionID == "" {
487486 return nil
488487 }
0 commit comments