object

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FavorTopic     = "favor_topic"
	FollowUser     = "follow_user"
	FavorNode      = "favor_node"
	SubscribeTopic = "subscribe_topic"
)

Variables

View Source
var (
	CasdoorOrganization string
	CasdoorApplication  string
)
View Source
var (
	DefaultPageNum             = 20
	DefaultHomePageNum         = 50
	DefaultNotificationPageNum = 10
	DefaultBalancePageNum      = 25
	DefaultFilePageNum         = 25
	DefaultMemberAdminPageNum  = 100
	DefaultRenameQuota         = 3
	UserNamingRestrictions     = false
	HomePageNodeNum            = 8
	TopicThanksCost            = 15
	ReplyThanksCost            = 10
	CreateTopicCost            = 20
	CreateReplyCost            = 5
	TopTopicCost               = 200
	ReceiveReplyBonus          = 5
	MaxDailyCheckinBonus       = 20
	LatestNodeNum              = 20
	HotNodeNum                 = 15
	HotTopicNum                = 10
	TopicEditableTime          = 10.0 // minutes
	ReplyEditableTime          = 10.0 // minutes
	ReplyDeletableTime         = 5.0  // minutes
	NodeHitRecordExpiredTime   = 1    // month
	TopicHitRecordExpiredTime  = 1    // day
	ValidateCodeExpiredTime    = 20   // minutes
	DefaultTopTopicTime        = 10   // minutes
	OnlineMemberExpiedTime     = 10   // minutes
	DefaultUploadFileQuota     = 50
	Domain                     = conf.GetConfigString("domain") // domain
	AutoSyncPeriodSecond       = -1                             // auto sync is disabled if < 30

	DefaultCronJobs = []*CronJob{
		{
			Id:       "updateExpiredData",
			BumpTime: "0:0",
			State:    "active",
		},
		{
			Id:       "updateHotInfo",
			BumpTime: "*/1:*",
			State:    "active",
		},
		{
			Id:       "expireData",
			BumpTime: "*/1:*",
			State:    "active",
		},
	}
	DefaultCronUpdates = []*UpdateJob{
		{
			Id:    "expireData",
			JobId: "updateExpiredData",
			State: "active",
		},
		{
			Id:    "hotInfo",
			JobId: "updateHotInfo",
			State: "active",
		},
		{
			Id:    "expireTopTopic",
			JobId: "expireData",
			State: "active",
		},
		{
			Id:    "expireOnlineMember",
			JobId: "expireData",
			State: "active",
		},
	}
)
View Source
var CasdoorStorageEndpoint = conf.GetConfigString("casdoorStorageEndpoint")
View Source
var Confs = []*FrontConf{
	{Id: "forumName", Value: "Casnode", Field: "visualConf", Tags: nil},
	{Id: "logoImage", Value: "https://cdn.casbin.com/forum/static/img/logo.png", Field: "visualConf", Tags: nil},
	{Id: "footerLogoImage", Value: "https://cdn.casbin.com/forum/static/img/logo-footer.png", Field: "visualConf", Tags: nil},
	{Id: "footerLogoUrl", Value: "https://www.digitalocean.com/", Field: "visualConf", Tags: nil},
	{Id: "signinBoxStrong", Value: "Casbin = way to authorization", Field: "visualConf", Tags: nil},
	{Id: "signinBoxSpan", Value: "A place for Casbin developers and users", Field: "visualConf", Tags: nil},
	{Id: "footerDeclaration", Value: "World is powered by code", Field: "visualConf", Tags: nil},
	{Id: "footerAdvise", Value: "♥ Do have faith in what you're doing.", Field: "visualConf", Tags: nil},
	{Id: "faq", Value: "Not yet", Field: "", Tags: nil},
	{Id: "mission", Value: "Not yet", Field: "", Tags: nil},
	{Id: "advertise", Value: "Not yet", Field: "", Tags: nil},
	{Id: "thanks", Value: "Not yet", Field: "", Tags: nil},
}

Functions

func AddBalance

func AddBalance(balance *ConsumptionRecord) bool

func AddBrowseRecordNum

func AddBrowseRecordNum(record *BrowseRecord) bool

func AddFavorites

func AddFavorites(favorite *Favorites) bool

func AddFileRecord

func AddFileRecord(record *UploadFileRecord) (bool, int)

func AddFileViewsNum

func AddFileViewsNum(id int) bool

func AddMemberByNameAndEmailIfNotExist

func AddMemberByNameAndEmailIfNotExist(username, email string) (*casdoorsdk.User, error)

func AddMemberFavorites

func AddMemberFavorites(memberId string, favoritesType string, objectId string) bool

func AddNode

func AddNode(node *Node) bool

func AddNodeModerators

func AddNodeModerators(memberId, nodeId string) bool

func AddNodes

func AddNodes(nodes []*Node) bool

func AddNotification

func AddNotification(notification *Notification) bool

func AddPlane

func AddPlane(plane *Plane) bool

func AddPoster

func AddPoster(poster Poster) bool

func AddReplies

func AddReplies(replies []*Reply) bool

func AddRepliesInBatch

func AddRepliesInBatch(relies []*Reply) bool

func AddReply

func AddReply(reply *Reply) (bool, int)

AddReply returns add reply result and reply id.

func AddReplyNotification

func AddReplyNotification(senderId, content string, objectId, topicId int)

func AddReplyThanksNum

func AddReplyThanksNum(id int) bool

AddReplyThanksNum updates reply's thanks num.

func AddSensitiveWord

func AddSensitiveWord(word string)

func AddTab

func AddTab(tab *Tab) bool

func AddTabs

func AddTabs(tabs []*Tab) bool

func AddTopic

func AddTopic(topic *Topic) (bool, int)

AddTopic return add topic result and topic id

func AddTopicHitCount

func AddTopicHitCount(topicId int) bool

func AddTopicNotification

func AddTopicNotification(objectId int, author, content string)

func AddTopics

func AddTopics(topics []*Topic) bool

func AddTopicsInBatch

func AddTopicsInBatch(topics []*Topic) bool

func AddTranslator

func AddTranslator(translator Translator) bool

func AutoSyncGitter added in v1.3.0

func AutoSyncGitter()

func AutoSyncGoogleGroup

func AutoSyncGoogleGroup()

func ChangeExpiredDataStatus

func ChangeExpiredDataStatus(recordType int, date string) int

func ChangeTopicFavoriteCount

func ChangeTopicFavoriteCount(topicId int, num int) bool

func ChangeTopicLastReplyUser

func ChangeTopicLastReplyUser(topicId int, memberId string, updateTime string) bool

func ChangeTopicReplyCount

func ChangeTopicReplyCount(topicId int, num int) bool

func ChangeTopicSubscribeCount

func ChangeTopicSubscribeCount(topicId int, num int) bool

func ChangeTopicTopExpiredTime

func ChangeTopicTopExpiredTime(id int, date, topType string) bool

ChangeTopicTopExpiredTime changes topic's top expired time. topType: tab, node or homePage.

func CheckIsAdmin

func CheckIsAdmin(user *casdoorsdk.User) bool

func CheckNodeModerator

func CheckNodeModerator(user *casdoorsdk.User, nodeId string) bool

func ContainsSensitiveWord

func ContainsSensitiveWord(str string) bool

func CreateReplyConsumption

func CreateReplyConsumption(user *casdoorsdk.User, id int) bool

func CreateTopicConsumption

func CreateTopicConsumption(user *casdoorsdk.User, id int) bool

func DelTranslator

func DelTranslator(id string) bool

func DeleteFavorites

func DeleteFavorites(memberId string, objectId string, favoritesType string) bool

func DeleteFileRecord

func DeleteFileRecord(id int) bool

func DeleteFilesByMember

func DeleteFilesByMember(memberId string) bool

func DeleteNode

func DeleteNode(id string) bool

func DeleteNodeModerators

func DeleteNodeModerators(memberId, nodeId string) bool

func DeleteNotification

func DeleteNotification(id string) bool

func DeletePlane

func DeletePlane(id string) bool

func DeleteRepliesHardByTopicId

func DeleteRepliesHardByTopicId(topicId int) bool

func DeleteReply

func DeleteReply(id int) bool

DeleteReply soft delete reply.

func DeleteSensitiveWord

func DeleteSensitiveWord(word string)

func DeleteTab

func DeleteTab(id string) bool

func DeleteTopic

func DeleteTopic(id int) bool

func DeleteTopicHard

func DeleteTopicHard(id int) bool

func DeletedExpiredData

func DeletedExpiredData(recordType int, date string) bool

func ExpireTopTopic

func ExpireTopTopic() int

ExpireTopTopic searches and expires expired top topic.

func FileEditable

func FileEditable(user *casdoorsdk.User, author string) bool

func FilterUnsafeHTML

func FilterUnsafeHTML(content string) string

func GetBrowseRecordNum

func GetBrowseRecordNum(recordType int, objectId string) int

func GetCreatedTopicsNum

func GetCreatedTopicsNum(memberId string) int

func GetDefaultTab

func GetDefaultTab() string

func GetFavoritesCount

func GetFavoritesCount() int

func GetFavoritesNum

func GetFavoritesNum(favoritesType string, memberId string) int

func GetFavoritesStatus

func GetFavoritesStatus(memberId string, objectId string, favoritesType string) bool

func GetFilesNum

func GetFilesNum(memberId string) int

func GetFollowingNum

func GetFollowingNum(id string) int

func GetForumVersion

func GetForumVersion() string

func GetHighestOnlineNum

func GetHighestOnlineNum() int

func GetLastRecordId

func GetLastRecordId() int

func GetLatestSyncedRecordId

func GetLatestSyncedRecordId() int

func GetMemberBalance

func GetMemberBalance(user *casdoorsdk.User) int

func GetMemberCheckinDate

func GetMemberCheckinDate(user *casdoorsdk.User) string

func GetMemberConsumptionRecordNum

func GetMemberConsumptionRecordNum(memberId string) int

func GetMemberEditorType

func GetMemberEditorType(user *casdoorsdk.User) string

func GetMemberEmailReminder

func GetMemberEmailReminder(id string) (bool, string)

GetMemberEmailReminder return member's email reminder status, and his email address.

func GetMemberFileQuota

func GetMemberFileQuota(user *casdoorsdk.User) int

func GetMemberLanguage

func GetMemberLanguage(user *casdoorsdk.User) string

func GetMemberNum

func GetMemberNum() int

func GetMemberRepliesNum

func GetMemberRepliesNum(memberId string) int

GetMemberRepliesNum returns member's all replies num.

func GetMembersFromFavorites

func GetMembersFromFavorites(objectId string, favoritesType string) []*casdoorsdk.User

func GetNodeFavoritesNum

func GetNodeFavoritesNum(id string) int

func GetNodeModerators

func GetNodeModerators(id string) []string

func GetNodeTopicNum

func GetNodeTopicNum(id string) int

func GetNodesNum

func GetNodesNum() int

func GetNotificationCount

func GetNotificationCount() int

func GetNotificationNum

func GetNotificationNum(memberId string) int

func GetOnlineMemberNum

func GetOnlineMemberNum() int

GetOnlineMemberNum returns online member num.

func GetOnlineUserCount

func GetOnlineUserCount() int

func GetPlaneNodesNum

func GetPlaneNodesNum(id string) int

func GetRankingPlayer

func GetRankingPlayer() ([]*casdoorsdk.User, error)

func GetRankingRich

func GetRankingRich() ([]*casdoorsdk.User, error)

func GetReplyAuthor

func GetReplyAuthor(id int) *casdoorsdk.User

GetReplyAuthor only returns reply's topic author.

func GetReplyBonus

func GetReplyBonus(author *casdoorsdk.User, consumer *casdoorsdk.User, id int)

func GetReplyCount

func GetReplyCount() int

GetReplyCount returns all replies num so far, both deleted and not deleted.

func GetReplyEditableStatus

func GetReplyEditableStatus(member, author, createdTime string) bool

GetReplyEditableStatus checks whether the reply can be edited.

func GetReplyTopicTitle

func GetReplyTopicTitle(id int) string

GetReplyTopicTitle only returns reply's topic title.

func GetSensitiveWords

func GetSensitiveWords() []string

func GetThanksStatus

func GetThanksStatus(memberId string, id, recordType int) bool

func GetTopicAuthor

func GetTopicAuthor(id int) *casdoorsdk.User

func GetTopicCount

func GetTopicCount() int

func GetTopicEditableStatus

func GetTopicEditableStatus(user *casdoorsdk.User, author, nodeId, createdTime string) bool

func GetTopicFavoritesNum added in v1.1.10

func GetTopicFavoritesNum(id string) int

func GetTopicNodeId

func GetTopicNodeId(id int) string

func GetTopicNum

func GetTopicNum() int

func GetTopicReplyNum

func GetTopicReplyNum(topicId int) int

GetTopicReplyNum returns topic's reply num.

func GetTopicSubscribeNum added in v1.1.10

func GetTopicSubscribeNum(id string) int

func GetTopicTitle

func GetTopicTitle(id int) string

func GetTranslator

func GetTranslator(id string) *[]Translator

func GetUnreadNotificationNum

func GetUnreadNotificationNum(memberId string) int

func GetUser

func GetUser(id string) *casdoorsdk.User

func GetUserByEmail

func GetUserByEmail(email string) *casdoorsdk.User

func GetUserField

func GetUserField(user *casdoorsdk.User, field string) string

func GetUserFieldInt

func GetUserFieldInt(user *casdoorsdk.User, field string) int

func GetUserName

func GetUserName(user *casdoorsdk.User) string

func GetUsers

func GetUsers() []*casdoorsdk.User

func HasNode

func HasNode(id string) bool

func HasPlane

func HasPlane(id string) bool

func HasTab

func HasTab(id string) bool

func InitAdapter

func InitAdapter()

func InitConfig

func InitConfig()

func InitForumBasicInfo

func InitForumBasicInfo()

func InitFrontConf

func InitFrontConf()

func InitHttpClient

func InitHttpClient()

func InitTimer

func InitTimer()

InitTimer initializes scheduled tasks.

func IsFavoritesExist

func IsFavoritesExist(Type string) bool

func IsForbidden

func IsForbidden(user *casdoorsdk.User) bool

IsForbidden check member whether is forbidden.

func IsSensitiveWord

func IsSensitiveWord(word string) bool

func RemoveHtmlTags

func RemoveHtmlTags(text string) string

func ReplyDeletable

func ReplyDeletable(date, memberId, author string) bool

ReplyDeletable checks whether the reply can be deleted.

func SetUserField

func SetUserField(user *casdoorsdk.User, field string, value string)

func SyncAllGitterRooms added in v1.3.0

func SyncAllGitterRooms()

func SyncAllNodeFromGoogleGroup

func SyncAllNodeFromGoogleGroup()

func TopTopicConsumption

func TopTopicConsumption(user *casdoorsdk.User, id int) bool

func UpdateFileDescribe

func UpdateFileDescribe(id int, fileName, desc string) bool

func UpdateFrontConfById added in v1.2.6

func UpdateFrontConfById(id string, value string, tags []string) (int64, error)

func UpdateFrontConfs added in v1.2.6

func UpdateFrontConfs(confs []*FrontConf) bool

func UpdateFrontConfsByField added in v1.2.6

func UpdateFrontConfsByField(confs []*FrontConf, field string) error

func UpdateHighestOnlineNum

func UpdateHighestOnlineNum(num int) bool

func UpdateHotNode

func UpdateHotNode(last int) int

func UpdateHotTopic

func UpdateHotTopic(last int) int

func UpdateLatestSyncedRecordId

func UpdateLatestSyncedRecordId(id int) bool

func UpdateMemberBalance

func UpdateMemberBalance(user *casdoorsdk.User, amount int) (bool, error)

func UpdateMemberCheckinDate

func UpdateMemberCheckinDate(user *casdoorsdk.User, checkinDate string) (bool, error)

func UpdateMemberConsumptionSum

func UpdateMemberConsumptionSum(user *casdoorsdk.User, amount int) (bool, error)

func UpdateMemberEditorType

func UpdateMemberEditorType(user *casdoorsdk.User, editorType string) (bool, error)

func UpdateMemberLanguage

func UpdateMemberLanguage(user *casdoorsdk.User, language string) (bool, error)

func UpdateMemberOnlineStatus

func UpdateMemberOnlineStatus(user *casdoorsdk.User, isOnline bool, lastActionDate string) (bool, error)

UpdateMemberOnlineStatus updates member's online information.

func UpdateNode

func UpdateNode(id string, node *Node) bool

func UpdateNodeHotInfo

func UpdateNodeHotInfo(nodeId string, hot int) bool

func UpdateOnlineMemberNum

func UpdateOnlineMemberNum()

UpdateOnlineMemberNum updates online member num and updates highest online member num at the same time.

func UpdatePlane

func UpdatePlane(id string, plane *Plane) bool

func UpdatePoster

func UpdatePoster(id string, poster Poster) bool

func UpdateReadStatus

func UpdateReadStatus(id string) bool

func UpdateReply

func UpdateReply(id int, reply *Reply) bool

UpdateReply updates reply's all field.

func UpdateReplyWithLimitCols

func UpdateReplyWithLimitCols(id int, reply *Reply) bool

UpdateReplyWithLimitCols updates reply's not null field.

func UpdateTab

func UpdateTab(id string, tab *Tab) bool

func UpdateTopic

func UpdateTopic(id int, topic *Topic) bool

func UpdateTopicHotInfo

func UpdateTopicHotInfo(topicId string, hot int) bool

func UpdateTopicWithLimitCols

func UpdateTopicWithLimitCols(id int, topic *Topic) bool

func UpdateTranslator

func UpdateTranslator(translator Translator) bool

Types

type Adapter

type Adapter struct {
	Engine *xorm.Engine
	// contains filtered or unexported fields
}

Adapter represents the MySQL adapter for policy storage.

func NewAdapter

func NewAdapter(driverName string, dataSourceName string, dbName string) *Adapter

NewAdapter is the constructor for Adapter.

type AdminMemberInfo

type AdminMemberInfo struct {
	casdoorsdk.User
	FileQuota     int    `json:"fileQuota"`
	FileUploadNum int    `json:"fileUploadNum"`
	Status        int    `json:"status"`
	TopicNum      int    `json:"topicNum"`
	ReplyNum      int    `json:"replyNum"`
	LatestLogin   string `json:"latestLogin"`
	Score         int    `json:"score"`
}

type AdminPlaneInfo

type AdminPlaneInfo struct {
	Plane
	Sorter   int     `json:"sorter"`
	Visible  bool    `json:"visible"`
	NodesNum int     `json:"nodesNum"`
	Nodes    []*Node `json:"nodes"`
}

func GetAllPlanes

func GetAllPlanes() []*AdminPlaneInfo

func GetPlaneAdmin

func GetPlaneAdmin(id string) *AdminPlaneInfo

type AdminTabInfo

type AdminTabInfo struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	Sorter      int    `json:"sorter"`
	CreatedTime string `json:"createdTime"`
	DefaultNode string `json:"defaultNode"`
	HomePage    bool   `json:"homePage"`
	NodesNum    int    `json:"nodesNum"`
	TopicsNum   int    `json:"topicsNum"`
}

func GetAllTabsAdmin

func GetAllTabsAdmin() []*AdminTabInfo

func GetTabAdmin

func GetTabAdmin(id string) *AdminTabInfo

GetTabAdmin returns more tab information for admin.

type AdminTopicInfo

type AdminTopicInfo struct {
	Topic
	Deleted bool `json:"deleted"`
}

func GetTopicAdmin

func GetTopicAdmin(id int) *AdminTopicInfo

func GetTopicsAdmin

func GetTopicsAdmin(usernameSearchKw, titleSearchKw, contentSearchKw, showDeletedTopic, createdTimeSort, lastReplySort, usernameSort, replyCountSort, hotSort, favCountSort string, limit int, offset int) ([]*AdminTopicInfo, int)

GetTopicsAdmin *sort: 1 means Asc, 2 means Desc, 0 means no effect.

type BalanceResponse

type BalanceResponse struct {
	Amount          int    `json:"amount"`
	Title           string `json:"title"`
	Length          int    `json:"length"`
	Balance         int    `json:"balance"`
	ObjectId        int    `json:"objectId"`
	ReceiverId      string `json:"receiverId"`
	ConsumerId      string `json:"consumerId"`
	CreatedTime     string `json:"createdTime"`
	ConsumptionType int    `json:"consumptionType"`
}

func GetMemberConsumptionRecord

func GetMemberConsumptionRecord(id string, limit, offset int) []*BalanceResponse

type BasicInfo

type BasicInfo struct {
	Id    string `xorm:"varchar(100) notnull pk"`
	Value string `xorm:"mediumtext"`
}

type BrowseRecord

type BrowseRecord struct {
	Id          int    `xorm:"int notnull pk autoincr" json:"id"`
	MemberId    string `xorm:"varchar(100)" json:"memberId"`
	RecordType  int    `xorm:"int" json:"recordType"`
	ObjectId    string `xorm:"varchar(100) index" json:"objectId"`
	CreatedTime string `xorm:"varchar(40) index" json:"createdTime"`
	Expired     bool   `xorm:"bool" json:"expired"`
}

RecordType: 1 means node hit record

type CommunityHealth

type CommunityHealth struct {
	Member int `json:"member"`
	Topic  int `json:"topic"`
	Reply  int `json:"reply"`
}

type ConsumptionRecord

type ConsumptionRecord struct {
	Id              int    `xorm:"int notnull pk autoincr" json:"id"`
	Amount          int    `xorm:"int" json:"amount"`
	Balance         int    `xorm:"int" json:"balance"`
	ConsumerId      string `xorm:"varchar(100) index" json:"consumerId"`
	ObjectId        int    `xorm:"int index" json:"objectId"`
	ReceiverId      string `xorm:"varchar(100) index" json:"receiverId"`
	CreatedTime     string `xorm:"varchar(40)" json:"createdTime"`
	ConsumptionType int    `xorm:"int" json:"consumptionType"`
}

ConsumptionType 1-9 means: login bonus, receive thanks(topic), receive thanks(reply), thanks(topic) thanks(reply), new reply, receive reply bonus, new topic, top topic.

func GetBalances

func GetBalances() []*ConsumptionRecord

func GetMemberBalances

func GetMemberBalances(id string, limit, offset int) []*ConsumptionRecord

type CronJob

type CronJob struct {
	Id       string `json:"id"`
	BumpTime string `json:"bumpTime"`
	State    string `json:"state"`
}

func GetCronJobs

func GetCronJobs() []*CronJob

func GetJobs

func GetJobs() []*CronJob

type Favorites

type Favorites struct {
	Id            int    `xorm:"int notnull pk autoincr" json:"id"`
	FavoritesType string `xorm:"varchar(100) index" json:"favoritesType"`
	ObjectId      string `xorm:"varchar(100) index" json:"objectId"`
	CreatedTime   string `xorm:"varchar(40)" json:"createdTime"`
	MemberId      string `xorm:"varchar(100) index" json:"memberId"`
}

type FrontConf

type FrontConf struct {
	Id    string   `xorm:"varchar(100) notnull pk" json:"id"`
	Value string   `xorm:"mediumtext" json:"value"`
	Field string   `xorm:"varchar(100)" json:"field"`
	Tags  []string `xorm:"varchar(200)" json:"tags"`
}

func GetFrontConfById

func GetFrontConfById(id string) *FrontConf

func GetFrontConfsByField added in v1.2.6

func GetFrontConfsByField(field string) []*FrontConf

type GoogleTranslationResult

type GoogleTranslationResult struct {
	Data struct {
		Translations []struct {
			TranslatedText         string `json:"translatedText"`
			DetectedSourceLanguage string `json:"detectedSourceLanguage"`
		} `json:"translations"`
	} `json:"data"`
	Error struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
		Errors  []struct {
			Message string `json:"message"`
			Domain  string `json:"domain"`
			Reason  string `json:"reason"`
		} `json:"errors"`
	} `json:"error"`
}

type LatestReply

type LatestReply struct {
	TopicId      int    `xorm:"id" json:"topicId"`
	NodeId       string `json:"nodeId"`
	NodeName     string `json:"nodeName"`
	Author       string `json:"author"`
	ReplyContent string `xorm:"content" json:"replyContent"`
	TopicTitle   string `xorm:"title" json:"topicTitle"`
	ReplyTime    string `xorm:"created_time" json:"replyTime"`
	TopicAuthor  string `xorm:"author" json:"topicAuthor"`
}

func GetLatestReplies

func GetLatestReplies(author string, limit int, offset int) []*LatestReply

GetLatestReplies returns member's latest replies.

type Node

type Node struct {
	Id                 string   `xorm:"varchar(100) notnull pk" json:"id"`
	Name               string   `xorm:"varchar(100)" json:"name"`
	CreatedTime        string   `xorm:"varchar(40)" json:"createdTime"`
	Desc               string   `xorm:"mediumtext" json:"desc"`
	Extra              string   `xorm:"mediumtext" json:"extra"`
	Image              string   `xorm:"varchar(200)" json:"image"`
	BackgroundImage    string   `xorm:"varchar(200)" json:"backgroundImage"`
	HeaderImage        string   `xorm:"varchar(200)" json:"headerImage"`
	BackgroundColor    string   `xorm:"varchar(20)" json:"backgroundColor"`
	BackgroundRepeat   string   `xorm:"varchar(20)" json:"backgroundRepeat"`
	TabId              string   `xorm:"varchar(100)" json:"tab"`
	ParentNode         string   `xorm:"varchar(200)" json:"parentNode"`
	PlaneId            string   `xorm:"varchar(50)" json:"planeId"`
	Sorter             int      `json:"sorter"`
	Ranking            int      `json:"ranking"`
	Hot                int      `json:"hot"`
	Moderators         []string `xorm:"varchar(200)" json:"moderators"`
	MailingList        string   `xorm:"varchar(100)" json:"mailingList"`
	GoogleGroupCookie  string   `xorm:"varchar(1500)" json:"googleGroupCookie"`
	GitterApiToken     string   `xorm:"varchar(200)" json:"gitterApiToken"`
	GitterRoomURL      string   `xorm:"varchar(200)" json:"gitterRoomUrl"`
	GitterSyncFromTime string   `xorm:"varchar(40)" json:"gitterSyncFromTime"`
	IsHidden           bool     `xorm:"bool" json:"isHidden"`
}

func GetHotNode

func GetHotNode(limit int) []*Node

func GetLatestNode

func GetLatestNode(limit int) []*Node

func GetNode

func GetNode(id string) *Node

func GetNodeFromPlane

func GetNodeFromPlane(plane string) []*Node

func GetNodeFromTab

func GetNodeFromTab(tab string) []*Node

func GetNodes

func GetNodes() []*Node

func GetNodesByTab

func GetNodesByTab(id string) []*Node

func (Node) AddTopicToMailingList

func (n Node) AddTopicToMailingList(title, content, author string)

func (Node) GetAllTopicTitlesOfNode

func (n Node) GetAllTopicTitlesOfNode() []string

func (Node) GetAllTopicsByNode added in v1.3.0

func (n Node) GetAllTopicsByNode() []Topic

func (Node) SyncFromGoogleGroup

func (n Node) SyncFromGoogleGroup()

func (Node) SyncGitter added in v1.3.0

func (n Node) SyncGitter()

type NodeFavoritesRes

type NodeFavoritesRes struct {
	NodeInfo *Node `json:"nodeInfo"`
	TopicNum int   `json:"topicNum"`
}

func GetNodesFromFavorites

func GetNodesFromFavorites(memberId string, limit int, offset int) []*NodeFavoritesRes

type NodeNavigationResponse

type NodeNavigationResponse struct {
	*Tab
	Nodes []*Node `json:"nodes"`
}

func GetNodeNavigation

func GetNodeNavigation() []*NodeNavigationResponse

type NodeRelation

type NodeRelation struct {
	ParentNode  *Node   `json:"parentNode"`
	RelatedNode []*Node `json:"relatedNode"`
	ChildNode   []*Node `json:"childNode"`
}

func GetNodeRelation

func GetNodeRelation(id string) *NodeRelation

type NodeTopic

type NodeTopic struct {
	Topic         `xorm:"extends"`
	Avatar        string `json:"avatar"`
	ThanksStatus  bool   `json:"thanksStatus"`
	Editable      bool   `json:"editable"`
	NodeModerator bool   `json:"nodeModerator"`
	ContentLength int    `json:"contentLength"`
}

func GetTopicsByNode

func GetTopicsByNode(nodeId string, limit int, offset int) []*NodeTopic

func GetTopicsByTag

func GetTopicsByTag(tagId string, limit int, offset int) []*NodeTopic

type Notification

type Notification struct {
	Id               int    `xorm:"int notnull pk autoincr" json:"id"`
	NotificationType int    `xorm:"int index" json:"notificationType"`
	ObjectId         int    `xorm:"int index" json:"objectId"`
	CreatedTime      string `xorm:"varchar(40)" json:"createdTime"`
	SenderId         string `xorm:"varchar(100)" json:"senderId"`
	ReceiverId       string `xorm:"varchar(100) index" json:"receiverId"`
	Status           int    `xorm:"tinyint" json:"-"`
}

NotificationType 1-6 means: reply(topic), mentioned(reply), mentioned(topic), favorite(topic), thanks(topic), thanks(reply) Status 1-3 means: unread, have read, deleted

type NotificationResponse

type NotificationResponse struct {
	*Notification `xorm:"extends"`
	Title         string `json:"title"`
	Content       string `json:"content"`
	Avatar        string `json:"avatar"`
}

func GetNotifications

func GetNotifications(memberId string, limit int, offset int) []*NotificationResponse

type Plane

type Plane struct {
	Id              string `xorm:"varchar(50) notnull pk" json:"id"`
	Name            string `xorm:"varchar(50)" json:"name"`
	Sorter          int    `xorm:"int" json:"-"`
	CreatedTime     string `xorm:"varchar(40)" json:"createdTime"`
	Image           string `xorm:"varchar(200)" json:"image"`
	BackgroundColor string `xorm:"varchar(20)" json:"backgroundColor"`
	Color           string `xorm:"varchar(20)" json:"color"`
	Visible         bool   `xorm:"bool" json:"-"`
}

func GetPlane

func GetPlane(id string) *Plane

func GetPlanes

func GetPlanes() []*Plane

type PlaneWithNodes

type PlaneWithNodes struct {
	*Plane
	Nodes []*Node `json:"nodes"`
}

func GetPlaneList

func GetPlaneList() []*PlaneWithNodes

type Poster

type Poster struct {
	Id          string `xorm:"varchar(50) notnull pk" json:"id"`
	Advertiser  string `xorm:"varchar(40)" json:"advertiser"`
	Link        string `xorm:"varchar(500)" json:"link"`
	PictureLink string `xorm:"varchar(500)" json:"picture_link"`
	State       string `xorm:"varchar(10)" json:"state"`
}

func GetPoster

func GetPoster(id string) *Poster

type Reply

type Reply struct {
	Id              int      `xorm:"int notnull pk autoincr" json:"id"`
	Author          string   `xorm:"varchar(100) index" json:"author"`
	TopicId         int      `xorm:"int index" json:"topicId"`
	ParentId        int      `xorm:"int" json:"parentId"`
	Tags            []string `xorm:"varchar(200)" json:"tags"`
	CreatedTime     string   `xorm:"varchar(40)" json:"createdTime"`
	Deleted         bool     `xorm:"bool" json:"deleted"`
	IsHidden        bool     `xorm:"bool" json:"isHidden"`
	ThanksNum       int      `xorm:"int" json:"thanksNum"`
	EditorType      string   `xorm:"varchar(40)" json:"editorType"`
	Content         string   `xorm:"mediumtext" json:"content"`
	Ip              string   `xorm:"varchar(100)" json:"ip"`
	State           string   `xorm:"varchar(100)" json:"state"`
	GitterMessageId string   `xorm:"varchar(100)" json:"gitterMessageId"`
}

func GetLatestReplyInfo

func GetLatestReplyInfo(topicId int) *Reply

GetLatestReplyInfo returns topic's latest reply information.

func GetRepliesOfTopic

func GetRepliesOfTopic(topicId int) []Reply

func GetReply

func GetReply(id int) *Reply

GetReply returns a single reply.

func GetReplyByContentAndAuthor added in v1.1.8

func GetReplyByContentAndAuthor(content string, author string) []*Reply

GetReplyByContentAndAuthor returns reply by content and author.

func SearchReplies

func SearchReplies(keyword string) []Reply

func (Reply) AddReplyToMailingList

func (r Reply) AddReplyToMailingList()

type ReplyWithAvatar

type ReplyWithAvatar struct {
	Reply             `xorm:"extends"`
	Avatar            string             `json:"avatar"`
	ThanksStatus      bool               `json:"thanksStatus"`
	Deletable         bool               `json:"deletable"`
	Editable          bool               `json:"editable"`
	ConsumptionAmount int                `xorm:"amount" json:"amount"`
	Child             []*ReplyWithAvatar `json:"child"`
}

func GetReplies

func GetReplies(topicId int, user *casdoorsdk.User, limit int, page int) ([]*ReplyWithAvatar, int)

@Title GetReplies @router /get-replies [get] @Description GetReplies returns more information about reply of a topic. @Tag Reply API

func GetRepliesFromFavorites

func GetRepliesFromFavorites(memberId string, limit int, offset int, favoritesType string) []*ReplyWithAvatar

func GetReplyWithDetails

func GetReplyWithDetails(user *casdoorsdk.User, id int) *ReplyWithAvatar

GetReplyWithDetails returns more information about reply, including avatar, thanks status, deletable and editable.

type SensitiveWord

type SensitiveWord struct {
	Word string `xorm:"varchar(64) notnull"`
	Id   int64
}

type Session

type Session struct {
	SessionKey    string  `xorm:"char(64) notnull pk"`
	SessionData   []uint8 `xorm:"blob"`
	SessionExpiry int     `xorm:"notnull"`
}

type Tab

type Tab struct {
	Id          string   `xorm:"varchar(100) notnull pk" json:"id"`
	Name        string   `xorm:"varchar(100)" json:"name"`
	Sorter      int      `json:"sorter"`
	Ranking     int      `json:"ranking"`
	CreatedTime string   `xorm:"varchar(40)" json:"-"`
	DefaultNode string   `xorm:"varchar(100)" json:"defaultNode"`
	HomePage    bool     `xorm:"bool" json:"-"`
	Desc        string   `xorm:"mediumtext" json:"desc"`
	Extra       string   `xorm:"mediumtext" json:"extra"`
	Moderators  []string `xorm:"varchar(200)" json:"moderators"`
}

func GetAllTabs

func GetAllTabs() []*Tab

func GetHomePageTabs

func GetHomePageTabs() []*Tab

func GetTab

func GetTab(id string) *Tab

type Topic

type Topic struct {
	Id              int      `xorm:"int notnull pk autoincr" json:"id"`
	Author          string   `xorm:"varchar(100) index" json:"author"`
	NodeId          string   `xorm:"varchar(100) index" json:"nodeId"`
	NodeName        string   `xorm:"varchar(100)" json:"nodeName"`
	TabId           string   `xorm:"varchar(100) index" json:"tabId"`
	Title           string   `xorm:"varchar(300) index" json:"title"`
	CreatedTime     string   `xorm:"varchar(40)" json:"createdTime"`
	Tags            []string `xorm:"varchar(200)" json:"tags"`
	ReplyCount      int      `json:"replyCount"`
	UpCount         int      `json:"upCount"`
	DownCount       int      `json:"downCount"`
	HitCount        int      `json:"hitCount"`
	Hot             int      `xorm:"index" json:"hot"`
	FavoriteCount   int      `json:"favoriteCount"`
	SubscribeCount  int      `json:"subscribeCount"`
	HomePageTopTime string   `xorm:"varchar(40) index(IDX_topic_htt_lrt)" json:"homePageTopTime"`
	TabTopTime      string   `xorm:"varchar(40) index(IDX_topic_ttt_lrt)" json:"tabTopTime"`
	NodeTopTime     string   `xorm:"varchar(40) index(IDX_topic_ntt_lrt)" json:"nodeTopTime"`
	LastReplyUser   string   `xorm:"varchar(100)" json:"lastReplyUser"`
	LastReplyTime   string   `xorm:"varchar(40) index(IDX_topic_htt_lrt) index(IDX_topic_ttt_lrt) index(IDX_topic_ntt_lrt)" json:"lastReplyTime"`
	Deleted         bool     `xorm:"bool index" json:"-"`
	EditorType      string   `xorm:"varchar(40)" json:"editorType"`
	Content         string   `xorm:"mediumtext" json:"content"`
	UrlPath         string   `xorm:"varchar(100)" json:"urlPath"`
	IsHidden        bool     `xorm:"bool index" json:"isHidden"`
	Ip              string   `xorm:"varchar(100)" json:"ip"`
	State           string   `xorm:"varchar(100)" json:"state"`
	GitterMessageId string   `xorm:"varchar(100)" json:"gitterMessageId"`
}

func GetAllCreatedTopics

func GetAllCreatedTopics(author string, tab string, limit int, offset int) []*Topic

func GetAllTopics

func GetAllTopics() []*Topic

func GetTopic

func GetTopic(id int) *Topic

func GetTopicBasicInfo

func GetTopicBasicInfo(id int) *Topic

func GetTopicByUrlPathAndTitle

func GetTopicByUrlPathAndTitle(urlPath, title, nodeId string) *Topic

func GetTopicsByTitleAndAuthor

func GetTopicsByTitleAndAuthor(title string, author string) []*Topic

func (Topic) GetAllRepliesOfTopic

func (t Topic) GetAllRepliesOfTopic() []string

type TopicWithAvatar

type TopicWithAvatar struct {
	Topic         `xorm:"extends"`
	Avatar        string `json:"avatar"`
	ThanksStatus  bool   `json:"thanksStatus"`
	Editable      bool   `json:"editable"`
	NodeModerator bool   `json:"nodeModerator"`
}

func GetFollowingNewAction

func GetFollowingNewAction(memberId string, limit int, offset int) []*TopicWithAvatar

func GetHotTopic

func GetHotTopic(limit int) []*TopicWithAvatar

func GetSortedTopics

func GetSortedTopics(lastReplySort, hotSort, favCountSort, createdTimeSort string, limit int, offset int) []*TopicWithAvatar

GetSortedTopics *sort: 1 means Asc, 2 means Desc, 0 means no effect.

func GetTopicWithAvatar

func GetTopicWithAvatar(id int, user *casdoorsdk.User) *TopicWithAvatar

func GetTopics

func GetTopics(limit int, offset int) []*TopicWithAvatar

func GetTopicsFromFavorites

func GetTopicsFromFavorites(memberId string, limit int, offset int, favoritesType string) []*TopicWithAvatar

func GetTopicsWithTab

func GetTopicsWithTab(tab string, limit, offset int) []*TopicWithAvatar

func SearchTopics

func SearchTopics(keyword string) []*TopicWithAvatar

type TranslateData

type TranslateData struct {
	SrcLang string `json:"srcLang"`
	Target  string `json:"target"`
	ErrMsg  string `json:"err_msg"`
}

func StrTranslate

func StrTranslate(srcStr, targetLang string) *TranslateData

type Translator

type Translator struct {
	Id         string `xorm:"varchar(50) notnull pk" json:"id"`
	Name       string `xorm:"varchar(50)" json:"name"`
	Translator string `xorm:"varchar(50)" json:"translator"`
	Key        string `xorm:"varchar(200)" json:"key"`
	Enable     bool   `xorm:"bool" json:"enable"`
	Visible    bool   `xorm:"bool" json:"visible"`
}

func GetEnableTranslator

func GetEnableTranslator() *Translator

type UpdateJob

type UpdateJob struct {
	Id      string `json:"id"`
	JobId   string `json:"jobId"`
	State   string `json:"state"`
	Url     string `json:"url"`
	Content string `json:"content"`
}

func GetCronUpdateJobs

func GetCronUpdateJobs() []*UpdateJob

func GetUpdateJob

func GetUpdateJob(id string) *UpdateJob

func GetUpdateJobs

func GetUpdateJobs(jobId string) []*UpdateJob

type UpdateListItem

type UpdateListItem struct {
	Table     string
	Attribute string
}

type UploadFileRecord

type UploadFileRecord struct {
	Id          int    `xorm:"int notnull pk autoincr" json:"id"`
	FileName    string `xorm:"varchar(100)" json:"fileName"`
	FilePath    string `xorm:"varchar(100)" json:"filePath"`
	FileUrl     string `xorm:"varchar(100)" json:"fileUrl"`
	FileType    string `xorm:"varchar(10)" json:"fileType"`
	FileExt     string `xorm:"varchar(20)" json:"fileExt"`
	MemberId    string `xorm:"varchar(100) index" json:"memberId"`
	CreatedTime string `xorm:"varchar(40)" json:"createdTime"`
	Size        int    `xorm:"int" json:"size"`
	Views       int    `xorm:"int" json:"views"`
	Desc        string `xorm:"varchar(500)" json:"desc"`
	Deleted     bool   `xorm:"bool" json:"-"`
}

func GetFile

func GetFile(id int) *UploadFileRecord

func GetFiles

func GetFiles(memberId string, limit, offset int) []*UploadFileRecord

Jump to

Keyboard shortcuts

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