-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✨ feat: Add settings page and UI components - Added new settings page with profile settings section - Created new UI components: Checkbox, Select, and Switch - Updated package.json with new Radix UI dependencies - Added settings.html entry point - Updated Vite config to include settings.html * 🔧 refactor: Remove chatbot functionality and refactor handlers (main) - Removed chatbot-related code including the `NewChatBot` function and associated handlers - Moved `initHandlerRequest` function to a separate `handler.go` file - Added job insertion logic to `saveBookmark` function in `websummary.go` - Updated error handling in bot middleware to conditionally print stack traces in debug mode - Removed chatbot initialization from main.go * ✨ feat: Add Telegram account linking functionality - Added new SQL query to get OAuth connection by provider and provider ID - Updated OAuth connection update query to include user ID - Implemented owner transfer functionality for bookmarks - Added new handler for linking Telegram account - Updated bot commands to include link account option - Added UI components for linking Telegram account in profile settings - Updated dependencies to include js-cookie for token management
- Loading branch information
Showing
29 changed files
with
697 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package auth | ||
|
||
import ( | ||
"context" | ||
"recally/internal/pkg/db" | ||
|
||
"github.com/google/uuid" | ||
"github.com/jackc/pgx/v5/pgtype" | ||
) | ||
|
||
func (s *Service) OwnerTransfer(ctx context.Context, tx db.DBTX, ownerID, newOwnerID uuid.UUID) error { | ||
return s.dao.OwnerTransferBookmark(ctx, tx, db.OwnerTransferBookmarkParams{ | ||
UserID: pgtype.UUID{Bytes: ownerID, Valid: ownerID != uuid.Nil}, | ||
UserID_2: pgtype.UUID{Bytes: newOwnerID, Valid: newOwnerID != uuid.Nil}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package handlers | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"recally/internal/pkg/auth" | ||
"recally/internal/pkg/contexts" | ||
"recally/internal/pkg/db" | ||
"strings" | ||
|
||
"github.com/jackc/pgx/v5" | ||
"gopkg.in/telebot.v3" | ||
) | ||
|
||
func (h *Handler) initHandlerRequest(c telebot.Context) (context.Context, *auth.UserDTO, db.DBTX, error) { | ||
ctx := c.Get(contexts.ContextKeyContext).(context.Context) | ||
|
||
tx, ok := contexts.Get[pgx.Tx](ctx, contexts.ContextKeyTx) | ||
if !ok { | ||
return nil, nil, nil, fmt.Errorf("failed to get dbtx from context") | ||
} | ||
|
||
userID, ok := contexts.Get[string](ctx, contexts.ContextKeyUserID) | ||
if !ok { | ||
return nil, nil, nil, fmt.Errorf("failed to get userID from context") | ||
} | ||
user, err := h.authService.GetTelegramUser(ctx, tx, userID) | ||
if err != nil { | ||
if strings.Contains(err.Error(), db.ErrNotFound) { | ||
userName := ctx.Value(contexts.ContextKey(contexts.ContextKeyUserName)).(string) | ||
user, err = h.authService.CreateTelegramUser(ctx, tx, userName, userID) | ||
if err != nil { | ||
return nil, nil, nil, fmt.Errorf("failed to create user: %w", err) | ||
} | ||
} else { | ||
return nil, nil, nil, fmt.Errorf("failed to get user: %w", err) | ||
} | ||
} | ||
|
||
return ctx, user, tx, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package handlers | ||
|
||
import ( | ||
"context" | ||
"recally/internal/pkg/auth" | ||
"recally/internal/pkg/contexts" | ||
"strings" | ||
|
||
"github.com/jackc/pgx/v5" | ||
tele "gopkg.in/telebot.v3" | ||
) | ||
|
||
func (h *Handler) LinkAccountHandler(c tele.Context) error { | ||
ctx := c.Get(contexts.ContextKeyContext).(context.Context) | ||
|
||
tx, ok := contexts.Get[pgx.Tx](ctx, contexts.ContextKeyTx) | ||
if !ok { | ||
_ = c.Reply("Failed to get dbtx from context") | ||
return nil | ||
} | ||
|
||
userID, ok := contexts.Get[string](ctx, contexts.ContextKeyUserID) | ||
if !ok { | ||
_ = c.Reply("Failed to get userID from context") | ||
return nil | ||
} | ||
|
||
token := strings.TrimSpace(strings.TrimPrefix(c.Text(), "/linkaccount")) | ||
if token == "" { | ||
_ = c.Reply("Invalid token") | ||
return nil | ||
} | ||
|
||
oAuthUser := auth.OAuth2User{ | ||
Provider: "telegram", | ||
ID: userID, | ||
Name: c.Sender().Username, | ||
} | ||
|
||
if err := h.authService.LinkAccount(ctx, tx, oAuthUser, token); err != nil { | ||
_ = c.Reply("Failed to link user: " + err.Error()) | ||
return nil | ||
} | ||
|
||
return c.Reply("User linked successfully") | ||
} |
Oops, something went wrong.