Skip to content

Commit

Permalink
Merge pull request #630 from cj123/acsr-geoip
Browse files Browse the repository at this point in the history
add geoip information to acsr request as part of query string
  • Loading branch information
Hecrer authored Nov 4, 2019
2 parents 68baf52 + 5ab0a02 commit f0f8d58
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 10 additions & 1 deletion acsr.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (

// Sends a championship to ACSR, called OnEndSession and when a championship is created
func ACSRSendResult(championship Championship) {
if config == nil || (config.ACSR.APIKey == "" || config.ACSR.AccountID == "" || !config.ACSR.Enabled) || len(championship.Events) == 0 {
if config == nil || (config.ACSR.APIKey == "" || config.ACSR.AccountID == "" || !config.ACSR.Enabled) ||
len(championship.Events) == 0 || IsPremium != "true" {
return
}

Expand Down Expand Up @@ -58,9 +59,17 @@ func ACSRSendResult(championship Championship) {
return
}

geoIP, err := geoIP()

if err != nil {
logrus.WithError(err).Error("couldn't get server geoIP for acsr request")
return
}

q := req.URL.Query()
q.Add("baseurl", config.HTTP.BaseURL)
q.Add("guid", config.ACSR.AccountID)
q.Add("geoip", geoIP.CountryName)
req.URL.RawQuery = q.Encode()
req.Header.Set("Content-Type", "application/json")

Expand Down
15 changes: 14 additions & 1 deletion cmd/server-manager/views/pages/championships/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,22 @@ <h1 class="text-center">
<label for="ACSR" class="col-sm-3 col-form-label">Export to <a href="https://acsr.assettocorsaservers.com">Assetto Corsa Skill Ratings</a></label>

<div class="col-sm-9">
<input type="checkbox" id="ACSR" name="ACSR"
<input type="checkbox" id="ACSR" name="ACSR" {{ if ne $.RaceTemplateVars.BaseTemplateVars.IsPremium "true" }} disabled="disabled" {{ end }}
{{ if $f.ACSR }} checked="checked" {{ end }}><br><br>


{{ if ne $.RaceTemplateVars.BaseTemplateVars.IsPremium "true" }}
<small class="text-warning">
Exporting to <a href="https://acsr.assettocorsaservers.com">ACSR</a> is a premium feature! You can access premium features by
<a href="https://assettocorsaservers.com">renting a server</a> or
<a href="https://paypal.me/JustaPenguinUK">going premium</a> with a minimum $10 donation,
thanks very much!
</small>

<br>
<br>
{{ end }}

<small>
If enabled then entrants in this championship will be (anonymously) tracked by our skill and safety
rating system! This championship will also be made publicly available for people to sign up from
Expand Down

0 comments on commit f0f8d58

Please sign in to comment.