utils

package
v0.0.0-...-7e087bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2024 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAzureBlobNotFound = errors.New("BlobNotFound")
View Source
var ErrAzureMismatchedMD5 = errors.New("MD5 hash of cached file mismatches database")
View Source
var ScoreSubmissionErrors *discordhook.WebhookAPI

Functions

func CacheQuaFile

func CacheQuaFile(m db.Map) (string, error)

CacheQuaFile Downloads a .qua file from the API to disk

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile Downloads a file from a URL

func FixMapNotFound

func FixMapNotFound(m *db.Map) error

FixMapNotFound Attempts to fix a missing map file from azure storage. This will find the mapset, retrieve the .qua from it, and upload it.

func GetFileMD5

func GetFileMD5(path string) (string, error)

GetFileMD5 Returns the MD5 hash of a file

func GetIpFromRequest

func GetIpFromRequest(c *gin.Context) string

GetIpFromRequest Gets the client's proper ip address from a request.

func InitializeAzure

func InitializeAzure()

InitializeAzure Initializes the azure storage client

func InitializeDiscordWebhooks

func InitializeDiscordWebhooks()

func IsValidMD5

func IsValidMD5(s string) bool

IsValidMD5 Returns if a string is a valid MD5 hash

func SendAnticheatWebhook

func SendAnticheatWebhook(user *db.User, mapData *db.Map, scoreId int, isPersonalBest bool, reason string) error

SendAnticheatWebhook Sends an anti-cheat related webhook to Discord

func SendFirstPlaceWebhook

func SendFirstPlaceWebhook(user *db.User, score *db.Score, m *db.Map, oldUser *db.User) error

SendFirstPlaceWebhook Sends a first place webhook

func SendFixedMapNotFoundWebhook

func SendFixedMapNotFoundWebhook(id int) error

SendFixedMapNotFoundWebhook Sends a webhook to Discord stating that a blob not found issue has been fixed.

func SendScoreSubmissionErrorWebhook

func SendScoreSubmissionErrorWebhook(user *db.User, reason string) error

SendScoreSubmissionErrorWebhook Sends a message to Discord that score submission has failed.

func SendScoreSubmissionWarningWebhook

func SendScoreSubmissionWarningWebhook(user *db.User, reason string) error

SendScoreSubmissionWarningWebhook Sends a message to Discord that a warning has occurred during score submission

func UpdateElasticSearchMapset

func UpdateElasticSearchMapset(id int) error

UpdateElasticSearchMapset Tells the API to update a mapset in elasticsearch

Types

type AzureStorageClient

type AzureStorageClient struct {
	// contains filtered or unexported fields
}
var AzureClient AzureStorageClient

AzureClient Global storage client used throughout the application. Must call InitializeAzure to create

func (*AzureStorageClient) DownloadFile

func (c *AzureStorageClient) DownloadFile(container string, name string, path string) (bytes.Buffer, error)

DownloadFile Downloads a blob from a given container

func (*AzureStorageClient) UploadFile

func (c *AzureStorageClient) UploadFile(container string, fileName string, data []byte) error

UploadFile Uploads a file to a given container

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL