services

package
v0.0.0-...-8e33b99 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const TruncatePostContentShortThreshold = 80
View Source
const TruncatePostContentThreshold = 160

Variables

This section is empty.

Functions

func AddPollAnswer

func AddPollAnswer(poll models.Poll, answer models.PollAnswer) (models.PollAnswer, error)

func AddPostView

func AddPostView(post models.Post, account uint)

func AddPostViews

func AddPostViews(posts []models.Post, account uint)

func BatchListPostReactions

func BatchListPostReactions(tx *gorm.DB, indexField string) (map[uint]map[string]int64, error)

func CountPost

func CountPost(tx *gorm.DB) (int64, error)

func CountPostReactions

func CountPostReactions(id uint) int64

func CountPostReply

func CountPostReply(id uint) int64

func CreateLanguageDetector

func CreateLanguageDetector() lingua.LanguageDetector

func CreateOrganizationPublisher

func CreateOrganizationPublisher(user authm.Account, realm authm.Realm, name, nick, desc, avatar, banner string) (models.Publisher, error)

func CreatePersonalPublisher

func CreatePersonalPublisher(user authm.Account, name, nick, desc, avatar, banner string) (models.Publisher, error)

func DeleteCategory

func DeleteCategory(category models.Category) error

func DeletePost

func DeletePost(item models.Post) error

func DeletePostInBatch

func DeletePostInBatch(items []models.Post) error

func DeletePublisher

func DeletePublisher(publisher models.Publisher) error

func DetectLanguage

func DetectLanguage(content string) string

func EditCategory

func EditCategory(category models.Category, alias, name, description string) (models.Category, error)

func EditPost

func EditPost(item models.Post, og models.Post) (models.Post, error)

func EditPublisher

func EditPublisher(user authm.Account, publisher, og models.Publisher) (models.Publisher, error)

func EnsurePostCategoriesAndTags

func EnsurePostCategoriesAndTags(item models.Post) (models.Post, error)

func FetchFediversePost

func FetchFediversePost(cfg FediverseFriendConfig) ([]models.FediversePost, error)

func FetchFediverseTimedTask

func FetchFediverseTimedTask()

func FilterPostDraft

func FilterPostDraft(tx *gorm.DB) *gorm.DB

func FilterPostDraftWithAuthor

func FilterPostDraftWithAuthor(tx *gorm.DB, uid uint) *gorm.DB

func FilterPostReply

func FilterPostReply(tx *gorm.DB, replyTo ...uint) *gorm.DB

func FilterPostWithAuthorDraft

func FilterPostWithAuthorDraft(tx *gorm.DB, uid uint) *gorm.DB

func FilterPostWithCategory

func FilterPostWithCategory(tx *gorm.DB, alias string) *gorm.DB

func FilterPostWithFuzzySearch

func FilterPostWithFuzzySearch(tx *gorm.DB, probe string) *gorm.DB

func FilterPostWithPublishedAt

func FilterPostWithPublishedAt(tx *gorm.DB, date time.Time, uid ...uint) *gorm.DB

func FilterPostWithRealm

func FilterPostWithRealm(tx *gorm.DB, probe string) *gorm.DB

func FilterPostWithTag

func FilterPostWithTag(tx *gorm.DB, alias string) *gorm.DB

func FilterPostWithType

func FilterPostWithType(tx *gorm.DB, t string) *gorm.DB

func FilterPostWithUserContext

func FilterPostWithUserContext(c *fiber.Ctx, tx *gorm.DB, user *authm.Account) *gorm.DB

func FlagCalculateCollapseStatus

func FlagCalculateCollapseStatus(post models.Post) error

func FlushPostViews

func FlushPostViews()

func GeneratePostInsights

func GeneratePostInsights(post models.Post, user uint) (string, error)

func GetAccountWithID

func GetAccountWithID(id uint) (models.Publisher, error)

func GetActivityID

func GetActivityID(uri string) activitypub.ID

func GetActivityIRI

func GetActivityIRI(uri string) activitypub.IRI

func GetCategory

func GetCategory(alias string) (models.Category, error)

func GetCategoryWithID

func GetCategoryWithID(id uint) (models.Category, error)

func GetConversation

func GetConversation(start uint, offset, take int, order string, participants []uint) ([]models.Post, error)

func GetFeaturedPosts

func GetFeaturedPosts(count int) ([]models.Post, error)

GetFeaturedPosts How to determine featured posts? Get the most upvoted posts in the last 7 days And then how to get the upvote count of each post in the last 7 days? We will get the reactions that attitude equals to 1 and created within the last 7 days By the way, the upvote count will subtract the downvote count Notice, this function is a raw query, it is not recommended to return the result directly Instead, you should get the id and query it again via the ListPost function

func GetPollMetric

func GetPollMetric(poll models.Poll) models.PollMetric

func GetPost

func GetPost(tx *gorm.DB, id uint) (models.Post, error)

func GetPostByAlias

func GetPostByAlias(tx *gorm.DB, alias, area string) (models.Post, error)

func GetPublisher

func GetPublisher(id uint, userID uint) (models.Publisher, error)

func GetPublisherByName

func GetPublisherByName(name string, userID uint) (models.Publisher, error)

func GetSubscriptionOnCategory

func GetSubscriptionOnCategory(user authm.Account, target models.Category) (*models.Subscription, error)

func GetSubscriptionOnTag

func GetSubscriptionOnTag(user authm.Account, target models.Tag) (*models.Subscription, error)

func GetSubscriptionOnUser

func GetSubscriptionOnUser(user authm.Account, target models.Publisher) (*models.Subscription, error)

func GetTag

func GetTag(alias string) (models.Tag, error)

func GetTagOrCreate

func GetTagOrCreate(alias, name string) (models.Tag, error)

func GetTagWithID

func GetTagWithID(id uint) (models.Tag, error)

func ListCategory

func ListCategory(take int, offset int) ([]models.Category, error)

func ListPost

func ListPost(tx *gorm.DB, take int, offset int, order any, user *uint, noReact ...bool) ([]*models.Post, error)

func ListPostInvisibleUser

func ListPostInvisibleUser(og models.Publisher, visibility models.PostVisibilityLevel) []uint

ListPostInvisibleUser will return a list of users which should not be notified the post. NOTICE If the visibility is PostVisibilitySelected, PostVisibilityFiltered or PostVisibilityNone, you need do extra steps to filter users WARNING This function won't use cache, be careful of the queries

func ListPostMinimal

func ListPostMinimal(tx *gorm.DB, take int, offset int, order any) ([]*models.Post, error)

func ListPostReactions

func ListPostReactions(tx *gorm.DB) (map[string]int64, error)

func ListTags

func ListTags(take int, offset int) ([]models.Tag, error)

func ModifyPosterVoteCount

func ModifyPosterVoteCount(user models.Publisher, isUpvote bool, delta int) error

func NewCategory

func NewCategory(alias, name, description string) (models.Category, error)

func NewFlag

func NewFlag(post models.Post, account uint) (models.PostFlag, error)

func NewPoll

func NewPoll(poll models.Poll) (models.Poll, error)

func NewPost

func NewPost(user models.Publisher, item models.Post) (models.Post, error)

func NotifyCategorySubscription

func NotifyCategorySubscription(poster models.Category, og models.Publisher, item models.Post, content string, title *string) error

func NotifyPosterAccount

func NotifyPosterAccount(pub models.Publisher, post models.Post, title, body, topic string, subtitle ...string) error

func NotifyTagSubscription

func NotifyTagSubscription(poster models.Tag, og models.Publisher, item models.Post, content string, title *string) error

func NotifyUserSubscription

func NotifyUserSubscription(poster models.Publisher, item models.Post, content string, title *string) error

func PinPost

func PinPost(post models.Post) (bool, error)

func PreloadGeneral

func PreloadGeneral(tx *gorm.DB) *gorm.DB

func ReactPost

func ReactPost(user authm.Account, reaction models.Reaction) (bool, models.Reaction, error)

func ReadFriendConfig

func ReadFriendConfig()

func SearchCategories

func SearchCategories(take int, offset int, probe string) ([]models.Category, error)

func SearchTags

func SearchTags(take int, offset int, probe string) ([]models.Tag, error)

func SubscribeToCategory

func SubscribeToCategory(user authm.Account, target models.Category) (models.Subscription, error)

func SubscribeToTag

func SubscribeToTag(user authm.Account, target models.Tag) (models.Subscription, error)

func SubscribeToUser

func SubscribeToUser(user authm.Account, target models.Publisher) (models.Subscription, error)

func TruncatePostContent

func TruncatePostContent(post models.Post) models.Post

func TruncatePostContentShort

func TruncatePostContentShort(content string) string

func UniversalPostFilter

func UniversalPostFilter(c *fiber.Ctx, tx *gorm.DB, cfg ...UniversalPostFilterConfig) (*gorm.DB, error)

func UnsubscribeFromCategory

func UnsubscribeFromCategory(user authm.Account, target models.Category) error

func UnsubscribeFromTag

func UnsubscribeFromTag(user authm.Account, target models.Tag) error

func UnsubscribeFromUser

func UnsubscribeFromUser(user authm.Account, target models.Publisher) error

func UpdatePoll

func UpdatePoll(poll models.Poll) (models.Poll, error)

func UpdatePostAttachmentMeta

func UpdatePostAttachmentMeta(item models.Post, old ...models.Post) error

Types

type FediverseFriendConfig

type FediverseFriendConfig struct {
	ID       string `json:"id"`
	URL      string `json:"url"`
	Type     string `json:"type"`
	Trending bool   `json:"trending"`
}

type FeedEntry

type FeedEntry struct {
	Type      string    `json:"type"`
	Data      any       `json:"data"`
	CreatedAt time.Time `json:"created_at"`
}

func GetFeed

func GetFeed(c *fiber.Ctx, limit int, user *uint, cursor *time.Time) ([]FeedEntry, error)

func ListFediversePostForFeed

func ListFediversePostForFeed(tx *gorm.DB, limit int) ([]FeedEntry, error)

func ListNewsForFeed

func ListNewsForFeed(limit int, cursor *time.Time) (FeedEntry, error)

func ListPostForFeed

func ListPostForFeed(tx *gorm.DB, limit int, user *uint) ([]FeedEntry, error)

type FromFediversePost

type FromFediversePost interface {
	ToFediversePost() models.FediversePost
}

type UniversalPostFilterConfig

type UniversalPostFilterConfig struct {
	ShowDraft     bool
	ShowReply     bool
	ShowCollapsed bool
	TimeCursor    *time.Time
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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