Compare commits
3 Commits
ac30cb5e4d
...
master
Author | SHA1 | Date | |
---|---|---|---|
25459cf429 | |||
c96e5bffa1 | |||
7dbb858d69 |
@@ -40,6 +40,8 @@ func createVideo(c *fiber.Ctx) error {
|
||||
VisibleUsers []uint `json:"visible_users_list"`
|
||||
InvisibleUsers []uint `json:"invisible_users_list"`
|
||||
Visibility *int8 `json:"visibility"`
|
||||
Renderer *string `json:"renderer"`
|
||||
IsLive bool `json:"is_live"`
|
||||
IsDraft bool `json:"is_draft"`
|
||||
Realm *uint `json:"realm"`
|
||||
}
|
||||
@@ -57,9 +59,11 @@ func createVideo(c *fiber.Ctx) error {
|
||||
Thumbnail: data.Thumbnail,
|
||||
Video: data.Video,
|
||||
Title: data.Title,
|
||||
Renderer: data.Renderer,
|
||||
Description: data.Description,
|
||||
Location: data.Location,
|
||||
Subtitles: data.Subtitles,
|
||||
IsLive: data.IsLive,
|
||||
}
|
||||
|
||||
var bodyMapping map[string]any
|
||||
@@ -136,6 +140,8 @@ func editVideo(c *fiber.Ctx) error {
|
||||
VisibleUsers []uint `json:"visible_users_list"`
|
||||
InvisibleUsers []uint `json:"invisible_users_list"`
|
||||
Visibility *int8 `json:"visibility"`
|
||||
Renderer *string `json:"renderer"`
|
||||
IsLive bool `json:"is_live"`
|
||||
IsDraft bool `json:"is_draft"`
|
||||
}
|
||||
|
||||
@@ -178,6 +184,8 @@ func editVideo(c *fiber.Ctx) error {
|
||||
Description: data.Description,
|
||||
Location: data.Location,
|
||||
Subtitles: data.Subtitles,
|
||||
Renderer: data.Renderer,
|
||||
IsLive: data.IsLive,
|
||||
}
|
||||
|
||||
var bodyMapping map[string]any
|
||||
|
@@ -102,6 +102,7 @@ type PostVideoBody struct {
|
||||
Description *string `json:"description"`
|
||||
Location *string `json:"location"`
|
||||
Video string `json:"video"`
|
||||
Renderer *string `json:"renderer"`
|
||||
IsLive bool `json:"is_live"`
|
||||
IsLiveEnded bool `json:"is_live_ended"`
|
||||
Subtitles map[string]string `json:"subtitles"`
|
||||
|
@@ -33,8 +33,8 @@ func GetFeed(c *fiber.Ctx, limit int, user *uint, cursor *time.Time) ([]FeedEntr
|
||||
|
||||
// Planing the feed
|
||||
limitF := float64(limit)
|
||||
interCount := int(math.Ceil(limitF * 0.5))
|
||||
readerCount := int(math.Ceil(limitF * 0.5))
|
||||
interCount := int(math.Ceil(limitF * 0.7))
|
||||
readerCount := int(math.Ceil(limitF * 0.3))
|
||||
|
||||
// Internal posts
|
||||
interTx, err := services.UniversalPostFilter(c, database.C)
|
||||
@@ -55,7 +55,7 @@ func GetFeed(c *fiber.Ctx, limit int, user *uint, cursor *time.Time) ([]FeedEntr
|
||||
})
|
||||
|
||||
// News today - from Reader
|
||||
if news, err := ListNewsForFeed(readerCount, cursor); err != nil {
|
||||
if news, err := ListReaderPagesForFeed(readerCount, cursor); err != nil {
|
||||
log.Error().Err(err).Msg("Failed to load news in getting feed...")
|
||||
} else {
|
||||
feed = append(feed, news...)
|
||||
@@ -70,10 +70,13 @@ func GetFeed(c *fiber.Ctx, limit int, user *uint, cursor *time.Time) ([]FeedEntr
|
||||
func ListPostForFeed(tx *gorm.DB, limit int, user *uint, api string) ([]FeedEntry, error) {
|
||||
var posts []models.Post
|
||||
var err error
|
||||
rankOrder := `(COALESCE(total_upvote, 0) - COALESCE(total_downvote, 0) +
|
||||
LOG(1 + COALESCE(total_aggressive_views, 0))) /
|
||||
POWER(EXTRACT(EPOCH FROM NOW() - published_at) / 3600 + 2, 1.5) DESC`
|
||||
if api == "2" {
|
||||
posts, err = ListPost(tx, limit, -1, "published_at DESC", user)
|
||||
posts, err = ListPost(tx, limit, -1, rankOrder, user)
|
||||
} else {
|
||||
posts, err = services.ListPost(tx, limit, -1, "published_at DESC", user)
|
||||
posts, err = services.ListPost(tx, limit, -1, rankOrder, user)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -88,7 +91,7 @@ func ListPostForFeed(tx *gorm.DB, limit int, user *uint, api string) ([]FeedEntr
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
func ListNewsForFeed(limit int, cursor *time.Time) ([]FeedEntry, error) {
|
||||
func ListReaderPagesForFeed(limit int, cursor *time.Time) ([]FeedEntry, error) {
|
||||
conn, err := gap.Nx.GetClientGrpcConn("re")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get grpc connection with reader: %v", err)
|
||||
|
@@ -2,6 +2,7 @@ package queries
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
|
||||
@@ -82,7 +83,7 @@ func CompletePostMeta(in ...models.Post) ([]models.Post, error) {
|
||||
attachmentsRid = append(attachmentsRid, bodies[idx].Attachments...)
|
||||
for _, field := range singularAttachmentFields {
|
||||
if raw, ok := info.Body[field]; ok {
|
||||
if str, ok := raw.(string); ok {
|
||||
if str, ok := raw.(string); ok && !strings.HasPrefix(str, "http") {
|
||||
attachmentsRid = append(attachmentsRid, str)
|
||||
}
|
||||
}
|
||||
@@ -132,9 +133,12 @@ func CompletePostMeta(in ...models.Post) ([]models.Post, error) {
|
||||
for _, field := range singularAttachmentFields {
|
||||
if raw, ok := item.Body[field]; ok {
|
||||
if str, ok := raw.(string); ok {
|
||||
item.Body[field] = lo.FindOrElse(this, fmodels.Attachment{}, func(item fmodels.Attachment) bool {
|
||||
result := lo.FindOrElse(this, fmodels.Attachment{}, func(item fmodels.Attachment) bool {
|
||||
return item.Rid == str
|
||||
})
|
||||
if result.ID != 0 {
|
||||
item.Body[field] = result
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user