Skip to content

Commit

Permalink
remove useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
madoka committed Apr 2, 2024
1 parent 6988ed6 commit b22723c
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 238 deletions.
214 changes: 0 additions & 214 deletions auth.go

This file was deleted.

14 changes: 0 additions & 14 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,13 @@ package main
import (
chatgpt_request_converter "freechatgpt/conversion/requests/chatgpt"
chatgpt "freechatgpt/internal/chatgpt"
"freechatgpt/internal/tokens"
official_types "freechatgpt/typings/official"
"sync"

"github.com/gin-gonic/gin"
"github.com/google/uuid"
)

func tokensHandler(c *gin.Context) {
// Get the request_tokens from the request (json) and update the request_tokens
var request_tokens map[string]tokens.Secret
err := c.BindJSON(&request_tokens)
if err != nil {
c.String(400, "tokens not provided")
return
}
ACCESS_TOKENS = tokens.NewAccessToken(request_tokens)
ACCESS_TOKENS.Save()
validAccounts = ACCESS_TOKENS.GetKeys()
c.String(200, "tokens updated")
}
func optionsHandler(c *gin.Context) {
// Set headers for CORS
c.Header("Access-Control-Allow-Origin", "*")
Expand Down
9 changes: 0 additions & 9 deletions internal/chatgpt/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,6 @@ func POSTconversation(message chatgpt_types.ChatGPTRequest, access_token string,
if err != nil {
return &http.Response{}, err
}
// Clear cookies
if puid != "" {
request.Header.Set("Cookie", "_puid="+puid+";")
}
request.Header.Set("Content-Type", "application/json")
request.Header.Set("User-Agent", userAgent)
request.Header.Set("Accept", "text/event-stream")
Expand All @@ -353,17 +349,13 @@ func POSTconversation(message chatgpt_types.ChatGPTRequest, access_token string,
if chat_token != "" {
request.Header.Set("Openai-Sentinel-Chat-Requirements-Token", chat_token)
}
if access_token != "" {
request.Header.Set("Authorization", "Bearer "+access_token)
}
if err != nil {
return &http.Response{}, err
}
response, err := client.Do(request)
return response, err
}

// Returns whether an error was handled
func Handle_request_error(c *gin.Context, response *http.Response) bool {
if response.StatusCode != 200 {
// Try read response body as JSON
Expand Down Expand Up @@ -653,7 +645,6 @@ func Handler(c *gin.Context, response *http.Response, token string, puid string,
}
}
endProcess:
// Flush the response writer buffer to ensure that the client receives each line as it's written
c.Writer.Flush()

if original_response.Message.Metadata.FinishDetails != nil {
Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func init() {
if PORT == "" {
PORT = "8080"
}
scheduleTokenPUID()
}
func main() {
router := gin.Default()
Expand Down

0 comments on commit b22723c

Please sign in to comment.