Documentation
¶
Index ¶
- Constants
- func AddPollAnswer(poll models.Poll, answer models.PollAnswer) (models.PollAnswer, error)
- func AddPostView(post models.Post, account uint)
- func AddPostViews(posts []models.Post, account uint)
- func BatchListPostReactions(tx *gorm.DB, indexField string) (map[uint]map[string]int64, error)
- func CountPost(tx *gorm.DB) (int64, error)
- func CountPostReactions(id uint) int64
- func CountPostReply(id uint) int64
- func CreateLanguageDetector() lingua.LanguageDetector
- func CreateOrganizationPublisher(user authm.Account, realm authm.Realm, name, nick, desc, avatar, banner string) (models.Publisher, error)
- func CreatePersonalPublisher(user authm.Account, name, nick, desc, avatar, banner string) (models.Publisher, error)
- func DeleteCategory(category models.Category) error
- func DeletePost(item models.Post) error
- func DeletePostInBatch(items []models.Post) error
- func DeletePublisher(publisher models.Publisher) error
- func DetectLanguage(content string) string
- func EditCategory(category models.Category, alias, name, description string) (models.Category, error)
- func EditPost(item models.Post, og models.Post) (models.Post, error)
- func EditPublisher(user authm.Account, publisher, og models.Publisher) (models.Publisher, error)
- func EnsurePostCategoriesAndTags(item models.Post) (models.Post, error)
- func FetchFediversePost(cfg FediverseFriendConfig) ([]models.FediversePost, error)
- func FetchFediverseTimedTask()
- func FilterPostDraft(tx *gorm.DB) *gorm.DB
- func FilterPostDraftWithAuthor(tx *gorm.DB, uid uint) *gorm.DB
- func FilterPostReply(tx *gorm.DB, replyTo ...uint) *gorm.DB
- func FilterPostWithAuthorDraft(tx *gorm.DB, uid uint) *gorm.DB
- func FilterPostWithCategory(tx *gorm.DB, alias string) *gorm.DB
- func FilterPostWithFuzzySearch(tx *gorm.DB, probe string) *gorm.DB
- func FilterPostWithPublishedAt(tx *gorm.DB, date time.Time, uid ...uint) *gorm.DB
- func FilterPostWithRealm(tx *gorm.DB, probe string) *gorm.DB
- func FilterPostWithTag(tx *gorm.DB, alias string) *gorm.DB
- func FilterPostWithType(tx *gorm.DB, t string) *gorm.DB
- func FilterPostWithUserContext(c *fiber.Ctx, tx *gorm.DB, user *authm.Account) *gorm.DB
- func FlagCalculateCollapseStatus(post models.Post) error
- func FlushPostViews()
- func GeneratePostInsights(post models.Post, user uint) (string, error)
- func GetAccountWithID(id uint) (models.Publisher, error)
- func GetActivityID(uri string) activitypub.ID
- func GetActivityIRI(uri string) activitypub.IRI
- func GetCategory(alias string) (models.Category, error)
- func GetCategoryWithID(id uint) (models.Category, error)
- func GetConversation(start uint, offset, take int, order string, participants []uint) ([]models.Post, error)
- func GetFeaturedPosts(count int) ([]models.Post, error)
- func GetPollMetric(poll models.Poll) models.PollMetric
- func GetPost(tx *gorm.DB, id uint) (models.Post, error)
- func GetPostByAlias(tx *gorm.DB, alias, area string) (models.Post, error)
- func GetPublisher(id uint, userID uint) (models.Publisher, error)
- func GetPublisherByName(name string, userID uint) (models.Publisher, error)
- func GetSubscriptionOnCategory(user authm.Account, target models.Category) (*models.Subscription, error)
- func GetSubscriptionOnTag(user authm.Account, target models.Tag) (*models.Subscription, error)
- func GetSubscriptionOnUser(user authm.Account, target models.Publisher) (*models.Subscription, error)
- func GetTag(alias string) (models.Tag, error)
- func GetTagOrCreate(alias, name string) (models.Tag, error)
- func GetTagWithID(id uint) (models.Tag, error)
- func ListCategory(take int, offset int) ([]models.Category, error)
- func ListPost(tx *gorm.DB, take int, offset int, order any, user *uint, noReact ...bool) ([]*models.Post, error)
- func ListPostInvisibleUser(og models.Publisher, visibility models.PostVisibilityLevel) []uint
- func ListPostMinimal(tx *gorm.DB, take int, offset int, order any) ([]*models.Post, error)
- func ListPostReactions(tx *gorm.DB) (map[string]int64, error)
- func ListTags(take int, offset int) ([]models.Tag, error)
- func ModifyPosterVoteCount(user models.Publisher, isUpvote bool, delta int) error
- func NewCategory(alias, name, description string) (models.Category, error)
- func NewFlag(post models.Post, account uint) (models.PostFlag, error)
- func NewPoll(poll models.Poll) (models.Poll, error)
- func NewPost(user models.Publisher, item models.Post) (models.Post, error)
- func NotifyCategorySubscription(poster models.Category, og models.Publisher, item models.Post, content string, ...) error
- func NotifyPosterAccount(pub models.Publisher, post models.Post, title, body, topic string, ...) error
- func NotifyTagSubscription(poster models.Tag, og models.Publisher, item models.Post, content string, ...) error
- func NotifyUserSubscription(poster models.Publisher, item models.Post, content string, title *string) error
- func PinPost(post models.Post) (bool, error)
- func PreloadGeneral(tx *gorm.DB) *gorm.DB
- func ReactPost(user authm.Account, reaction models.Reaction) (bool, models.Reaction, error)
- func ReadFriendConfig()
- func SearchCategories(take int, offset int, probe string) ([]models.Category, error)
- func SearchTags(take int, offset int, probe string) ([]models.Tag, error)
- func SubscribeToCategory(user authm.Account, target models.Category) (models.Subscription, error)
- func SubscribeToTag(user authm.Account, target models.Tag) (models.Subscription, error)
- func SubscribeToUser(user authm.Account, target models.Publisher) (models.Subscription, error)
- func TruncatePostContent(post models.Post) models.Post
- func TruncatePostContentShort(content string) string
- func UniversalPostFilter(c *fiber.Ctx, tx *gorm.DB, cfg ...UniversalPostFilterConfig) (*gorm.DB, error)
- func UnsubscribeFromCategory(user authm.Account, target models.Category) error
- func UnsubscribeFromTag(user authm.Account, target models.Tag) error
- func UnsubscribeFromUser(user authm.Account, target models.Publisher) error
- func UpdatePoll(poll models.Poll) (models.Poll, error)
- func UpdatePostAttachmentMeta(item models.Post, old ...models.Post) error
- type FediverseFriendConfig
- type FeedEntry
- func GetFeed(c *fiber.Ctx, limit int, user *uint, cursor *time.Time) ([]FeedEntry, error)
- func ListFediversePostForFeed(tx *gorm.DB, limit int) ([]FeedEntry, error)
- func ListNewsForFeed(limit int, cursor *time.Time) (FeedEntry, error)
- func ListPostForFeed(tx *gorm.DB, limit int, user *uint) ([]FeedEntry, error)
- type FromFediversePost
- type UniversalPostFilterConfig
Constants ¶
const TruncatePostContentShortThreshold = 80
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 AddPostViews ¶
func BatchListPostReactions ¶
func CountPostReactions ¶
func CountPostReply ¶
func CreateLanguageDetector ¶
func CreateLanguageDetector() lingua.LanguageDetector
func CreatePersonalPublisher ¶
func DeleteCategory ¶
func DeletePost ¶
func DeletePostInBatch ¶
func DeletePublisher ¶
func DetectLanguage ¶
func EditCategory ¶
func EditPublisher ¶
func FetchFediversePost ¶
func FetchFediversePost(cfg FediverseFriendConfig) ([]models.FediversePost, error)
func FetchFediverseTimedTask ¶
func FetchFediverseTimedTask()
func FlushPostViews ¶
func FlushPostViews()
func GetActivityID ¶
func GetActivityID(uri string) activitypub.ID
func GetActivityIRI ¶
func GetActivityIRI(uri string) activitypub.IRI
func GetConversation ¶
func GetFeaturedPosts ¶
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 GetPublisherByName ¶
func GetSubscriptionOnTag ¶
func GetSubscriptionOnUser ¶
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 ModifyPosterVoteCount ¶
func NotifyPosterAccount ¶
func NotifyTagSubscription ¶
func NotifyUserSubscription ¶
func ReadFriendConfig ¶
func ReadFriendConfig()
func SearchCategories ¶
func SubscribeToCategory ¶
func SubscribeToTag ¶
func SubscribeToUser ¶
func UniversalPostFilter ¶
func UnsubscribeFromCategory ¶
func UnsubscribeFromUser ¶
Types ¶
type FediverseFriendConfig ¶
type FeedEntry ¶
type FeedEntry struct { Type string `json:"type"` Data any `json:"data"` CreatedAt time.Time `json:"created_at"` }
type FromFediversePost ¶
type FromFediversePost interface {
ToFediversePost() models.FediversePost
}