Skip to content

Commit a135435

Browse files
committed
feature: Added new functions
1 parent 9838936 commit a135435

File tree

27 files changed

+370
-29
lines changed

27 files changed

+370
-29
lines changed

app/handlers/extension.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package handlers
2+
3+
import (
4+
"github.com/gofiber/fiber/v2"
5+
"github.com/limanmys/render-engine/internal/liman"
6+
)
7+
8+
func ExtensionRunner(c *fiber.Ctx) error {
9+
/*if len(c.FormValue("extension_id")) < 1 {
10+
return fiber.NewError(fiber.StatusNotFound, "Extension not found")
11+
}
12+
13+
extension, err := liman.GetExtension(&models.Extension{
14+
ID: c.FormValue("extension_id"),
15+
})
16+
17+
if err != nil {
18+
return err
19+
}
20+
21+
if extension.Status == "0" {
22+
return fiber.NewError(fiber.StatusServiceUnavailable, "Extension is unavailable right now, please try again later.")
23+
}
24+
25+
if extension.RequireKey == "true" {
26+
credentials, err := liman.GetCredentials(
27+
&models.User{
28+
ID: c.Locals("user_id").(string),
29+
},
30+
&models.Server{
31+
ID: c.FormValue("server_id"),
32+
},
33+
)
34+
35+
if err != nil || len(credentials.Username) < 1 {
36+
return fiber.NewError(fiber.StatusForbidden, "You need a key to use this extension, please add it through the case.")
37+
}
38+
} */
39+
40+
settings := liman.GetSettings(c.Locals("user_id").(string), c.FormValue("server_id"), c.FormValue("extension_id"))
41+
42+
return c.JSON(settings)
43+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
package controllers
1+
package handlers
22

33
import (
44
"github.com/gofiber/fiber/v2"
55
"github.com/limanmys/render-engine/app/models"
6-
"github.com/limanmys/render-engine/internal/bridge"
6+
"github.com/limanmys/render-engine/internal/liman"
77
)
88

99
func CredentialTest(c *fiber.Ctx) error {
1010

11-
credentials, err := bridge.GetCredentials(
11+
credentials, err := liman.GetCredentials(
1212
&models.User{
13-
ID: c.Params("user"),
13+
ID: c.Locals("user_id").(string),
1414
},
1515
&models.Server{
1616
ID: c.Params("server"),

app/models/php_command.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package models
2+
3+
type CommandParams struct {
4+
TargetFunction string
5+
User string
6+
Extension string
7+
Server string
8+
RequestData map[string]string
9+
Token string
10+
BaseURL string
11+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (ServerKey) TableName() string {
2727
return "server_keys"
2828
}
2929

30-
func (d KeyData) DecryptKey(user *User, server *Server) *Credentials {
30+
func (d KeyData) DecryptData(user *User, server *Server) *Credentials {
3131
key := os.Getenv("APP_KEY") + user.ID + server.ID
3232

3333
return &Credentials{

app/models/settings.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package models
2+
3+
type Settings struct {
4+
ID string `json:"id"`
5+
ServerID string `json:"server_id"`
6+
UserID string `json:"user_id"`
7+
Name string `json:"name"`
8+
Value string `json:"value"`
9+
CreatedAt string `json:"created_at"`
10+
UpdatedAt string `json:"updated_at"`
11+
}
12+
13+
func (Settings) TableName() string {
14+
return "user_settings"
15+
}
File renamed without changes.

0 commit comments

Comments
 (0)