Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44fe1ce

Browse files
committed
fixes
1 parent 8f40450 commit 44fe1ce

20 files changed

Lines changed: 558 additions & 4789 deletions

File tree

.air.toml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#:schema https://json.schemastore.org/any.json
2+
3+
env_files = []
4+
root = "."
5+
testdata_dir = "testdata"
6+
tmp_dir = "tmp"
7+
8+
[build]
9+
args_bin = []
10+
bin = "./tmp/main"
11+
cmd = "go build -o ./tmp/main ."
12+
delay = 1000
13+
entrypoint = ["./tmp/main"]
14+
exclude_dir = ["assets", "tmp", "vendor", "testdata","static","workers"]
15+
exclude_file = []
16+
exclude_regex = ["_test.go"]
17+
exclude_unchanged = false
18+
follow_symlink = false
19+
full_bin = ""
20+
ignore_dangerous_root_dir = false
21+
include_dir = []
22+
include_ext = ["go", "tpl", "tmpl", "html"]
23+
include_file = []
24+
kill_delay = "0s"
25+
log = "build-errors.log"
26+
poll = false
27+
poll_interval = 0
28+
post_cmd = []
29+
pre_cmd = []
30+
rerun = false
31+
rerun_delay = 500
32+
send_interrupt = false
33+
stop_on_error = false
34+
35+
[color]
36+
app = ""
37+
build = "yellow"
38+
main = "magenta"
39+
runner = "green"
40+
watcher = "cyan"
41+
42+
[log]
43+
main_only = false
44+
silent = false
45+
time = false
46+
47+
[misc]
48+
clean_on_exit = false
49+
50+
[proxy]
51+
app_port = 0
52+
app_start_timeout = 0
53+
enabled = false
54+
proxy_port = 0
55+
56+
[screen]
57+
clear_on_rebuild = false
58+
keep_scroll = true

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ require (
2929
github.com/go-shiori/dom v0.0.0-20230515143342-73569d674e1c // indirect
3030
github.com/go-sql-driver/mysql v1.9.3 // indirect
3131
github.com/gofiber/schema v1.7.0 // indirect
32+
github.com/gofiber/template v1.8.3 // indirect
33+
github.com/gofiber/template/html/v2 v2.1.3 // indirect
34+
github.com/gofiber/utils v1.1.0 // indirect
3235
github.com/gofiber/utils/v2 v2.0.2 // indirect
3336
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f // indirect
3437
github.com/google/go-cmp v0.7.0 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ github.com/gofiber/fiber/v3 v3.1.0 h1:1p4I820pIa+FGxfwWuQZ5rAyX0WlGZbGT6Hnuxt6hK
186186
github.com/gofiber/fiber/v3 v3.1.0/go.mod h1:n2nYQovvL9z3Too/FGOfgtERjW3GQcAUqgfoezGBZdU=
187187
github.com/gofiber/schema v1.7.0 h1:yNM+FNRZjyYEli9Ey0AXRBrAY9jTnb+kmGs3lJGPvKg=
188188
github.com/gofiber/schema v1.7.0/go.mod h1:A/X5Ffyru4p9eBdp99qu+nzviHzQiZ7odLT+TwxWhbk=
189+
github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc=
190+
github.com/gofiber/template v1.8.3/go.mod h1:bs/2n0pSNPOkRa5VJ8zTIvedcI/lEYxzV3+YPXdBvq8=
191+
github.com/gofiber/template/html/v2 v2.1.3 h1:n1LYBtmr9C0V/k/3qBblXyMxV5B0o/gpb6dFLp8ea+o=
192+
github.com/gofiber/template/html/v2 v2.1.3/go.mod h1:U5Fxgc5KpyujU9OqKzy6Kn6Qup6Tm7zdsISR+VpnHRE=
193+
github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM=
194+
github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0=
189195
github.com/gofiber/utils/v2 v2.0.2 h1:ShRRssz0F3AhTlAQcuEj54OEDtWF7+HJDwEi/aa6QLI=
190196
github.com/gofiber/utils/v2 v2.0.2/go.mod h1:+9Ub4NqQ+IaJoTliq5LfdmOJAA/Hzwf4pXOxOa3RrJ0=
191197
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=

middleware/web.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package middleware
2+
3+
import (
4+
services "core/services/user"
5+
"core/types"
6+
7+
"github.com/gofiber/fiber/v3"
8+
)
9+
10+
func WebMiddleware(s *services.PostService) fiber.Handler {
11+
12+
var (
13+
cachedCategories any
14+
cachedStars any
15+
cachedPreferences any
16+
)
17+
18+
return func(c fiber.Ctx) error {
19+
20+
if cachedCategories == nil || cachedStars == nil || cachedPreferences == nil {
21+
domain := "porn"
22+
23+
categories, err := s.GetPillarsWithClusters(types.Filter{
24+
Domain: &domain,
25+
})
26+
27+
stars, _, userErr := s.UserRepo().FetchNearbyUsers(types.Filter{
28+
Domain: &domain,
29+
Limit: 20,
30+
})
31+
32+
preferences, prefErr := s.UserRepo().GetPreferences()
33+
34+
if err == nil {
35+
cachedCategories = categories
36+
}
37+
38+
if userErr == nil {
39+
cachedStars = stars
40+
}
41+
42+
if prefErr == nil {
43+
cachedPreferences = preferences
44+
}
45+
}
46+
47+
c.Locals("Categories", cachedCategories)
48+
c.Locals("Stars", cachedStars)
49+
c.Locals("Preferences", cachedPreferences)
50+
return c.Next()
51+
}
52+
}

models/domain.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ type DomainKind string
1010
const (
1111
CoolVibes DomainKind = "coolvibes"
1212
KewlSwap DomainKind = "kewlswap"
13-
Porn DomainKind = "porn"
1413
UnknownDomain DomainKind = "unknown"
1514
AllDomains DomainKind = "all"
1615
)
@@ -33,13 +32,6 @@ var domainToKind = map[string]DomainKind{
3332
"api.kewlswap.com": KewlSwap,
3433
"api.kewlswap.io": KewlSwap,
3534
"api.kewlswap.app": KewlSwap,
36-
37-
// Porn
38-
"cilwe.com": Porn,
39-
"api.cilwe.com": Porn,
40-
"127.0.0.1": Porn,
41-
"localhost": Porn,
42-
"porn": Porn,
4335
}
4436

4537
func NormalizeDomain(input string) string {

models/sitemap/video_types.go

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,46 @@ type VideoURLItem struct {
1616

1717
type VideoMeta struct {
1818
ThumbnailLoc string `xml:"video:thumbnail_loc"`
19-
Title string `xml:"video:title"`
20-
Description string `xml:"video:description"`
21-
ContentLoc string `xml:"video:content_loc,omitempty"`
22-
PlayerLoc string `xml:"video:player_loc,omitempty"`
23-
Duration int `xml:"video:duration,omitempty"`
19+
20+
Title string `xml:"video:title"`
21+
Description string `xml:"video:description"`
22+
23+
ContentLoc string `xml:"video:content_loc,omitempty"`
24+
PlayerLoc string `xml:"video:player_loc,omitempty"`
25+
26+
Duration int `xml:"video:duration,omitempty"`
27+
28+
ExpirationDate string `xml:"video:expiration_date,omitempty"`
29+
30+
Rating float64 `xml:"video:rating,omitempty"`
31+
ViewCount int64 `xml:"video:view_count,omitempty"`
32+
33+
PublicationDate string `xml:"video:publication_date,omitempty"`
34+
35+
FamilyFriendly string `xml:"video:family_friendly,omitempty"`
36+
37+
Restriction *VideoRestriction `xml:"video:restriction,omitempty"`
38+
39+
Price *VideoPrice `xml:"video:price,omitempty"`
40+
41+
RequiresSubscription string `xml:"video:requires_subscription,omitempty"`
42+
43+
Uploader *VideoUploader `xml:"video:uploader,omitempty"`
44+
45+
Live string `xml:"video:live,omitempty"`
46+
}
47+
48+
type VideoRestriction struct {
49+
Relationship string `xml:"relationship,attr"`
50+
Value string `xml:",chardata"`
51+
}
52+
53+
type VideoPrice struct {
54+
Currency string `xml:"currency,attr"`
55+
Value string `xml:",chardata"`
56+
}
57+
58+
type VideoUploader struct {
59+
Info string `xml:"info,attr"`
60+
Name string `xml:",chardata"`
2461
}

proxies.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

repositories/sitemap_repository.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (r *SitemapRepository) BuildNewsSitemap(
120120
}
121121

122122
urlSet.URLs = append(urlSet.URLs, sitemap.NewsURL{
123-
Loc: fmt.Sprintf("%s/news/%s", baseURL, *p.Slug),
123+
Loc: fmt.Sprintf("%s/%s/%s", baseURL, p.PostKind, *p.Slug),
124124
News: sitemap.NewsMeta{
125125
Publication: sitemap.Publication{
126126
Name: siteName,
@@ -208,7 +208,7 @@ func (r *SitemapRepository) BuildPostSitemap(
208208
}
209209

210210
urlSet.URLs = append(urlSet.URLs, sitemap.URL{
211-
Loc: fmt.Sprintf("%s/news/%s", baseURL, *p.Slug),
211+
Loc: fmt.Sprintf("%s/%s/%s", baseURL, p.PostKind, *p.Slug),
212212
LastMod: p.UpdatedAt.UTC().Format(time.RFC3339),
213213
Priority: priority,
214214
ChangeFreq: map[bool]string{true: "hourly", false: "daily"}[age <= 24*time.Hour],
@@ -223,20 +223,36 @@ func (r *SitemapRepository) BuildPostSitemap(
223223
return append([]byte(xml.Header), output...), nil
224224
}
225225

226-
func (r *SitemapRepository) GeneratePillarSitemap(ctx context.Context, baseURL string) ([]byte, error) {
226+
func (r *SitemapRepository) GenerateCategoriesSitemap(ctx context.Context, baseURL string) ([]byte, error) {
227227

228228
var pillars []taxonomy.Pillar
229229
r.db.Find(&pillars)
230230

231+
err := r.db.
232+
Preload("Clusters").
233+
Find(&pillars).Error
234+
235+
if err != nil {
236+
return nil, err
237+
}
238+
231239
builder := sitemap.NewSitemapBuilder(baseURL)
232240

233241
var items []sitemap.SitemapItem
234242

235243
for _, p := range pillars {
244+
236245
items = append(items, sitemap.SitemapItem{
237-
Loc: builder.BuildLoc("pillar/" + p.Slug),
246+
Loc: builder.BuildLoc("/" + p.Slug),
238247
LastMod: p.UpdatedAt.UTC().Format(time.RFC3339),
239248
})
249+
250+
for _, c := range p.Clusters {
251+
items = append(items, sitemap.SitemapItem{
252+
Loc: builder.BuildLoc("/" + p.Slug + "/" + c.Slug),
253+
LastMod: c.UpdatedAt.UTC().Format(time.RFC3339),
254+
})
255+
}
240256
}
241257

242258
return builder.BuildURLSitemap(items)

repositories/user_repository.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,3 +831,11 @@ func (r *UserRepository) AddBalance(ctx context.Context, userID uuid.UUID, amoun
831831

832832
return &newBalance, nil
833833
}
834+
835+
func (r *UserRepository) GetPreferences() (*models.PreferencesData, error) {
836+
var preferences models.PreferencesData
837+
if err := r.DB().Model(&models.Preferences{}).Select("data").First(&preferences).Error; err != nil {
838+
return nil, err
839+
}
840+
return &preferences, nil
841+
}

routes/handlers/filter.go

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ import (
1212
"github.com/google/uuid"
1313
)
1414

15+
func getParam(c fiber.Ctx, key string) string {
16+
v := c.Params(key)
17+
if v == "" {
18+
v = c.Query(key)
19+
}
20+
if v == "" {
21+
v = c.FormValue(key)
22+
}
23+
return v
24+
}
25+
1526
func ParseFilters(c fiber.Ctx, authUser *models.User) (types.Filter, error) {
1627
filter := types.Filter{
1728
AuthUser: authUser,
@@ -78,37 +89,31 @@ func ParseFilters(c fiber.Ctx, authUser *models.User) (types.Filter, error) {
7889
filter.Search = &search
7990
}
8091

81-
//slug
82-
slug := c.Query("slug")
83-
if slug == "" {
84-
slug = c.Query("slug")
85-
}
86-
if slug == "" {
87-
slug = c.FormValue("slug")
92+
if slug := getParam(c, "slug"); slug != "" {
93+
filter.Slug = &slug
8894
}
89-
if slug == "" {
90-
slug = c.FormValue("slug")
95+
96+
if pillar := getParam(c, "pillar"); pillar != "" {
97+
filter.Pillar = &pillar
9198
}
92-
if slug != "" {
93-
filter.Slug = &slug
99+
100+
if cluster := getParam(c, "cluster"); cluster != "" {
101+
filter.Cluster = &cluster
94102
}
95103

96-
if category := c.FormValue("category"); category != "" {
104+
if category := getParam(c, "category"); category != "" {
97105
filter.Category = &category
98106
}
99107

100-
// Name
101-
if name := c.FormValue("name"); name != "" {
108+
if name := getParam(c, "name"); name != "" {
102109
filter.Name = &name
103110
}
104111

105-
// City
106-
if city := c.FormValue("city"); city != "" {
112+
if city := getParam(c, "city"); city != "" {
107113
filter.City = &city
108114
}
109115

110-
// Country
111-
if country := c.FormValue("country"); country != "" {
116+
if country := getParam(c, "country"); country != "" {
112117
filter.Country = &country
113118
}
114119

@@ -159,5 +164,6 @@ func ParseFilters(c fiber.Ctx, authUser *models.User) (types.Filter, error) {
159164
filter.Domain = &kind
160165
}
161166

167+
fmt.Println("GELEN DOMAIN", host, *filter.Domain)
162168
return filter, nil
163169
}

0 commit comments

Comments
 (0)