Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions api/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (h *EmailHandler) handleAccountInfo(w http.ResponseWriter, r *http.Request)
return
}

accountInfo, err := h.emailService.GetAccountInfo(r.Context(), &account)
accountInfo, err := h.emailService.GetAccountInfo(r.Context(), account)
if err != nil {
errors.HandleError(w, r, err)
return
Expand Down Expand Up @@ -377,7 +377,7 @@ func (h *EmailHandler) handleRemoveAccount(w http.ResponseWriter, r *http.Reques

if err := h.authService.Authorize(&config.AuthRequest{
User: user,
Ressource: &account,
Ressource: account,
Actions: []string{auth.ActionDelete},
Context: r.Context(),
}); err != nil {
Expand Down Expand Up @@ -406,7 +406,7 @@ func (h *EmailHandler) handleShareAccount(w http.ResponseWriter, r *http.Request

if err := h.authService.Authorize(&config.AuthRequest{
User: user,
Ressource: &account,
Ressource: account,
Actions: []string{auth.ActionShare},
Context: r.Context(),
}); err != nil {
Expand Down Expand Up @@ -447,7 +447,7 @@ func (h *EmailHandler) handleRemoveAccountShare(w http.ResponseWriter, r *http.R

if err := h.authService.Authorize(&config.AuthRequest{
User: user,
Ressource: &account,
Ressource: account,
Actions: []string{auth.ActionShare},
Context: r.Context(),
}); err != nil {
Expand All @@ -461,12 +461,7 @@ func (h *EmailHandler) handleRemoveAccountShare(w http.ResponseWriter, r *http.R
return
}

params := repository.DeleteShareParams{
UserId: sharingUser.ID,
Account: account.ID,
}

if err := h.emailService.RemoveShare(r.Context(), params); err != nil {
if err := h.emailService.RemoveShare(r.Context(), sharingUser.ID, account.ID); err != nil {
errors.HandleError(w, r, err)
return
}
Expand Down
23 changes: 9 additions & 14 deletions database/repository/email.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions database/repository/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 9 additions & 14 deletions database/repository/sessions.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 12 additions & 17 deletions database/repository/users.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions services/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type AuthService interface {
AuthMiddleware(next http.Handler) http.Handler

// session management
GetUserSessions(ctx context.Context, userId int32) ([]repository.UserSession, error)
GetUserSessions(ctx context.Context, userId int32) ([]*repository.UserSession, error)
DeleteUserSession(ctx context.Context, userId, id int32) error
DeleteUserSessions(ctx context.Context, userId int32) error
}
Expand Down Expand Up @@ -225,12 +225,12 @@ func (s *realAuthService) AuthMiddleware(next http.Handler) http.Handler {
})
}

func (s *realAuthService) GetUserSessions(ctx context.Context, userId int32) ([]repository.UserSession, error) {
func (s *realAuthService) GetUserSessions(ctx context.Context, userId int32) ([]*repository.UserSession, error) {
return database.Queries.GetUserSessions(ctx, userId)
}

func (s *realAuthService) DeleteUserSession(ctx context.Context, userId, id int32) error {
return database.Queries.DeleteSessionById(ctx, repository.DeleteSessionByIdParams{UserId: userId, ID: id})
return database.Queries.DeleteSessionById(ctx, userId, id)
}

func (s *realAuthService) DeleteUserSessions(ctx context.Context, userId int32) error {
Expand Down
8 changes: 4 additions & 4 deletions services/email/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ type AccountInfo struct {
Shares []string `json:"shares"`
}

func (r *realEmailService) GetAccountByEmail(ctx context.Context, email string) (repository.MailAccount, error) {
func (r *realEmailService) GetAccountByEmail(ctx context.Context, email string) (*repository.MailAccount, error) {
return database.Queries.GetMailAccountByEmail(ctx, email)
}

func (r *realEmailService) ListAccounts(ctx context.Context, userId int32) ([]repository.MailAccount, error) {
func (r *realEmailService) ListAccounts(ctx context.Context, userId int32) ([]*repository.MailAccount, error) {
return database.Queries.ListUserMailAccounts(ctx, userId)
}

Expand Down Expand Up @@ -93,8 +93,8 @@ func (r *realEmailService) AddShare(ctx context.Context, params repository.AddSh
return database.Queries.AddShare(ctx, params)
}

func (r *realEmailService) RemoveShare(ctx context.Context, params repository.DeleteShareParams) error {
return database.Queries.DeleteShare(ctx, params)
func (r *realEmailService) RemoveShare(ctx context.Context, userId, accountId int32) error {
return database.Queries.DeleteShare(ctx, userId, accountId)
}

func (r *realEmailService) GetAccountShares(ctx context.Context, account int32) ([]int32, error) {
Expand Down
Loading