-
Notifications
You must be signed in to change notification settings - Fork 41
[inbox] introduce module and API placeholders #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
capcom6
wants to merge
3
commits into
master
Choose a base branch
from
codex/implement-/inbox-routes-returning-not-implemented
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,84 @@ | ||
| package inbox | ||
|
|
||
| import ( | ||
| "github.com/android-sms-gateway/server/internal/sms-gateway/handlers/base" | ||
| "github.com/android-sms-gateway/server/internal/sms-gateway/handlers/middlewares/permissions" | ||
| "github.com/android-sms-gateway/server/internal/sms-gateway/handlers/middlewares/userauth" | ||
| "github.com/android-sms-gateway/server/internal/sms-gateway/inbox" | ||
| "github.com/go-playground/validator/v10" | ||
| "github.com/gofiber/fiber/v2" | ||
| "go.uber.org/zap" | ||
| ) | ||
|
|
||
| type ThirdPartyController struct { | ||
| base.Handler | ||
|
|
||
| inboxSvc *inbox.Service | ||
| } | ||
|
|
||
| func NewThirdPartyController( | ||
| inboxSvc *inbox.Service, | ||
| logger *zap.Logger, | ||
| validator *validator.Validate, | ||
| ) *ThirdPartyController { | ||
| return &ThirdPartyController{ | ||
| Handler: base.Handler{ | ||
| Logger: logger, | ||
| Validator: validator, | ||
| }, | ||
|
|
||
| inboxSvc: inboxSvc, | ||
| } | ||
| } | ||
|
|
||
| func (h *ThirdPartyController) Register(router fiber.Router) { | ||
| router.Get("", permissions.RequireScope(ScopeList), userauth.WithUserID(h.list)) | ||
| router.Post("/refresh", permissions.RequireScope(ScopeRefresh), userauth.WithUserID(h.refresh)) | ||
| } | ||
|
|
||
| // @Summary Get incoming messages | ||
| // @Description Retrieves incoming messages with filtering and pagination. | ||
| // @Security ApiAuth | ||
| // @Security JWTAuth | ||
| // @Tags User, Inbox | ||
| // @Produce json | ||
| // @Param type query string false "Filter incoming messages by type" Enums(SMS,DATA_SMS,MMS,MMS_DOWNLOADED) | ||
| // @Param limit query int false "Maximum number of messages to return" minimum(1) maximum(500) default(50) | ||
| // @Param offset query int false "Number of messages to skip" minimum(0) default(0) | ||
| // @Param from query string false "Start of date range (ISO 8601)" Format(date-time) | ||
| // @Param to query string false "End of date range (ISO 8601)" Format(date-time) | ||
| // @Param deviceId query string false "Device ID" | ||
| // @Success 200 {array} smsgateway.IncomingMessage "A list of incoming messages" | ||
| // @Header 200 {integer} X-Total-Count "Total number of items available" | ||
| // @Failure 400 {object} smsgateway.ErrorResponse "Invalid request" | ||
| // @Failure 401 {object} smsgateway.ErrorResponse "Unauthorized" | ||
| // @Failure 403 {object} smsgateway.ErrorResponse "Forbidden" | ||
| // @Failure 500 {object} smsgateway.ErrorResponse "Internal server error" | ||
| // @Failure 501 {object} smsgateway.ErrorResponse "Not implemented" | ||
| // @Router /3rdparty/v1/inbox [get] | ||
| // | ||
| // Get incoming messages. | ||
| func (h *ThirdPartyController) list(_ string, _ *fiber.Ctx) error { | ||
| return fiber.NewError(fiber.StatusNotImplemented, "Inbox API is not implemented yet") | ||
| } | ||
|
|
||
| // @Summary Request inbox messages refresh | ||
| // @Description Refreshes inbox messages. Webhooks will not be triggered. | ||
| // @Security ApiAuth | ||
| // @Security JWTAuth | ||
| // @Tags User, Inbox | ||
| // @Accept json | ||
| // @Produce json | ||
| // @Param request body smsgateway.MessagesExportRequest true "Export inbox request" | ||
| // @Success 202 {object} object "Inbox refresh request accepted" | ||
| // @Failure 400 {object} smsgateway.ErrorResponse "Invalid request" | ||
| // @Failure 401 {object} smsgateway.ErrorResponse "Unauthorized" | ||
| // @Failure 403 {object} smsgateway.ErrorResponse "Forbidden" | ||
| // @Failure 500 {object} smsgateway.ErrorResponse "Internal server error" | ||
| // @Failure 501 {object} smsgateway.ErrorResponse "Not implemented" | ||
| // @Router /3rdparty/v1/inbox/refresh [post] | ||
| // | ||
| // Request inbox refresh. | ||
| func (h *ThirdPartyController) refresh(_ string, _ *fiber.Ctx) error { | ||
| return fiber.NewError(fiber.StatusNotImplemented, "Inbox API is not implemented yet") | ||
| } |
This file contains hidden or 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,6 @@ | ||
| package inbox | ||
|
|
||
| const ( | ||
| ScopeList = "inbox:list" | ||
| ScopeRefresh = "inbox:refresh" | ||
| ) |
This file contains hidden or 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 hidden or 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 hidden or 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 inbox | ||
|
|
||
| import ( | ||
| "github.com/go-core-fx/logger" | ||
| "go.uber.org/fx" | ||
| ) | ||
|
|
||
| func Module() fx.Option { | ||
| return fx.Module( | ||
| "inbox", | ||
| logger.WithNamedLogger("inbox"), | ||
| fx.Provide( | ||
| New, | ||
| ), | ||
| ) | ||
| } |
This file contains hidden or 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,33 @@ | ||
| package inbox | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "time" | ||
|
|
||
| "github.com/android-sms-gateway/server/internal/sms-gateway/modules/events" | ||
| "go.uber.org/zap" | ||
| ) | ||
|
|
||
| type Service struct { | ||
| eventsSvc *events.Service | ||
|
|
||
| logger *zap.Logger | ||
| } | ||
|
|
||
| func New(eventsSvc *events.Service, logger *zap.Logger) *Service { | ||
| return &Service{ | ||
| eventsSvc: eventsSvc, | ||
|
|
||
| logger: logger, | ||
| } | ||
| } | ||
|
|
||
| func (s *Service) Refresh(userID string, deviceID *string, since, until time.Time) error { | ||
| event := events.NewMessagesExportRequestedEvent(since, until) | ||
|
|
||
| if err := s.eventsSvc.Notify(userID, deviceID, event); err != nil { | ||
| return fmt.Errorf("failed to notify device: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.