2024-08-06 19:28:55 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2024-09-19 18:24:06 +00:00
|
|
|
"context"
|
2024-08-06 19:28:55 +00:00
|
|
|
"database/sql"
|
|
|
|
|
|
|
|
persistence "github.com/status-im/status-go/services/connector/database"
|
|
|
|
"github.com/status-im/status-go/signal"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RevokePermissionsCommand struct {
|
|
|
|
Db *sql.DB
|
|
|
|
}
|
|
|
|
|
2024-09-19 18:24:06 +00:00
|
|
|
func (c *RevokePermissionsCommand) Execute(ctx context.Context, request RPCRequest) (interface{}, error) {
|
2024-08-06 19:28:55 +00:00
|
|
|
err := request.Validate()
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
dApp, err := persistence.SelectDAppByUrl(c.Db, request.URL)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
if dApp == nil {
|
|
|
|
return "", ErrDAppIsNotPermittedByUser
|
|
|
|
}
|
|
|
|
|
|
|
|
err = persistence.DeleteDApp(c.Db, dApp.URL)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
signal.SendConnectorDAppPermissionRevoked(signal.ConnectorDApp{
|
|
|
|
URL: request.URL,
|
|
|
|
Name: request.Name,
|
|
|
|
IconURL: request.IconURL,
|
|
|
|
})
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|