File tree 4 files changed +42
-0
lines changed
4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 10
10
" 127.0.0.1"
11
11
]
12
12
},
13
+ "api_v1" : {
14
+ "url" : " http://localhost:8082" ,
15
+ "secret_key" : " "
16
+ },
13
17
"steam" : {
14
18
"app_id" : 980610 ,
15
19
"publisher_key" : " " ,
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ type Config struct {
21
21
RateLimitIpWhitelist []string `json:"rate_limit_ip_whitelist"`
22
22
} `json:"server"`
23
23
24
+ ApiV1 struct {
25
+ Url string `json:"url"`
26
+ SecretKey string `json:"secret_key"`
27
+ } `json:"api_v1"`
28
+
24
29
Steam struct {
25
30
AppId int `json:"app_id"`
26
31
PublisherKey string `json:"publisher_key"`
Original file line number Diff line number Diff line change @@ -4,8 +4,10 @@ import (
4
4
"github.com/Quaver/api2/config"
5
5
"github.com/Quaver/api2/db"
6
6
"github.com/Quaver/api2/enums"
7
+ v1 "github.com/Quaver/api2/v1"
7
8
"github.com/Quaver/api2/webhooks"
8
9
"github.com/gin-gonic/gin"
10
+ "github.com/sirupsen/logrus"
9
11
"gorm.io/gorm"
10
12
"net/http"
11
13
"strconv"
@@ -155,6 +157,10 @@ func VoteForRankingQueueMapset(c *gin.Context) *APIError {
155
157
return APIErrorServerError ("Error inserting ranked mapset notification" , err )
156
158
}
157
159
160
+ if err := v1 .UpdateElasticSearchMapset (data .QueueMapset .MapsetId ); err != nil {
161
+ logrus .Warn ("Error updating v1 elastic search for mapset: " , data .QueueMapset .MapsetId , err )
162
+ }
163
+
158
164
_ = webhooks .SendRankedWebhook (data .QueueMapset .Mapset , existingVotes )
159
165
}
160
166
Original file line number Diff line number Diff line change
1
+ package v1
2
+
3
+ import (
4
+ "fmt"
5
+ "github.com/Quaver/api2/config"
6
+ "github.com/go-resty/resty/v2"
7
+ )
8
+
9
+ // UpdateElasticSearchMapset Makes an API call to v1 to update elastic search for a given mapset
10
+ func UpdateElasticSearchMapset (id int ) error {
11
+ resp , err := resty .New ().R ().
12
+ SetHeader ("Accept" , "application/json" ).
13
+ SetBody (map [string ]interface {}{
14
+ "key" : config .Instance .ApiV1 .SecretKey ,
15
+ "id" : id ,
16
+ }).Post (fmt .Sprintf ("%v/v1/mapsets/elastic" , config .Instance .ApiV1 .Url ))
17
+
18
+ if err != nil {
19
+ return err
20
+ }
21
+
22
+ if resp .IsError () {
23
+ return fmt .Errorf ("request to update elastic mapset (v1) failed: %v" , resp .Error ())
24
+ }
25
+
26
+ return nil
27
+ }
You can’t perform that action at this time.
0 commit comments