server

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTwitterProjectID = "dessage"
	DefaultDBTimeOut        = 10 * time.Second
	DBTableNJUser           = "ninja-user"
	DBTableTWUser           = "twitter-user"
	DBTableTWUserAccToken   = "twitter-user-access-token"
	DBTableTWUserAccTokenV2 = "twitter-user-access-token_v2"
	DBTableWeb3Bindings     = "twitter-eth-binding"
	DBTableTweetsPosted     = "tweets-posted"
	DBTableTweetsStatus     = "tweets-status"
)
View Source
const (
	BuyRightsUrlKey = "twOwner"
)
View Source
const (
	SessionNameSystem = "session-name-for-ninja"
)
View Source
const (
	Web3IDProfile = "Dessage-Web3-ID:"
)

Variables

This section is empty.

Functions

func InitConf

func InitConf(c *SysConf)

Types

type BlockChainConf

type BlockChainConf struct {
	TweeTVoteContractAddress string `json:"tweet_vote_contract_address"`
	GameContract             string `json:"game_contract"`
	KolKeyContractAddress    string `json:"kol_key_contract_address"`
	InfuraUrl                string `json:"infura_url"`
	GameTimeInMinute         int    `json:"game_time_in_minute,omitempty"`
	TxCheckerInSeconds       int    `json:"tx_checker_in_seconds,omitempty"`
	ChainID                  int64  `json:"chain_id,omitempty"`
}

func (*BlockChainConf) String

func (c *BlockChainConf) String() string

type DbManager

type DbManager struct {
	// contains filtered or unexported fields
}

func DbInst

func DbInst() *DbManager

func (*DbManager) BindingWeb3ID

func (dm *DbManager) BindingWeb3ID(bindData *Web3Binding, twMeta *TWUserInfo) (*NinjaUsrInfo, error)

func (*DbManager) GetTwAccessToken

func (dm *DbManager) GetTwAccessToken(twitterId string) (*TwUserAccessToken, error)

func (*DbManager) GetTwAccessTokenV2

func (dm *DbManager) GetTwAccessTokenV2(twitterId string) (*TwUserAccessTokenV2, error)

func (*DbManager) NjTweetDetails

func (dm *DbManager) NjTweetDetails(createAt int64) (*NinjaTweet, error)

func (*DbManager) NjUserSignIn

func (dm *DbManager) NjUserSignIn(ethAddr string) *NinjaUsrInfo

func (*DbManager) QueryGlobalLatestTweets

func (dm *DbManager) QueryGlobalLatestTweets(pageSize int, id int64, readNewest bool, callback func(tweet *NinjaTweet)) error

func (*DbManager) QueryTweetStatus

func (dm *DbManager) QueryTweetStatus(createTimes []int64) (map[int64]*NjTweetStatus, error)

func (*DbManager) SaveTwAccessToken

func (dm *DbManager) SaveTwAccessToken(token *TwUserAccessToken) error

func (*DbManager) SaveTwAccessTokenV2

func (dm *DbManager) SaveTwAccessTokenV2(token *TwUserAccessTokenV2) error

func (*DbManager) SaveTweet

func (dm *DbManager) SaveTweet(content *NinjaTweet) error

func (*DbManager) TwitterBasicInfo

func (dm *DbManager) TwitterBasicInfo(TID string) (*TWUserInfo, error)

func (*DbManager) UpdateBasicInfo

func (dm *DbManager) UpdateBasicInfo(twData *TWUserInfo) error

func (*DbManager) UpdateTweetPaymentStatus

func (dm *DbManager) UpdateTweetPaymentStatus(createAt int64, s TxStatus) error

func (*DbManager) UpdateTweetVoteStatic

func (dm *DbManager) UpdateTweetVoteStatic(createAt int64, amount int) (int, error)

type FileStoreConf

type FileStoreConf struct {
	ProjectID      string `json:"project_id"`
	KeyFilePath    string `json:"key_file_path"`
	TweetsPageSize int    `json:"tweets_page_size"`
}

func (*FileStoreConf) String

func (c *FileStoreConf) String() string

type Geo

type Geo struct {
	PlaceID string `json:"place_id,omitempty"`
}

type HttpConf

type HttpConf struct {
	RefreshContent bool   `json:"refresh_content"`
	UseHttps       bool   `json:"use_https"`
	SSLCertFile    string `json:"ssl_cert_file"`
	SSLKeyFile     string `json:"ssl_key_file"`
	SessionKey     string `json:"session_key"`
	// contains filtered or unexported fields
}

func (*HttpConf) String

func (c *HttpConf) String() string

type LogicAction

type LogicAction struct {
	Action    func(w http.ResponseWriter, r *http.Request, token *NinjaUsrInfo)
	NeedToken bool
}

type MainService

type MainService struct {
}

func NewMainService

func NewMainService() *MainService

func (*MainService) Start

func (bh *MainService) Start()

type Media

type Media struct {
	MediaIDs      []string `json:"media_ids,omitempty"`
	TaggedUserIDs []string `json:"tagged_user_ids,omitempty"`
}

type NinjaTweet

type NinjaTweet struct {
	Txt           string   `json:"text" firestore:"text"`
	CreateAt      int64    `json:"create_time" firestore:"create_time"`
	Web3ID        string   `json:"web3_id" firestore:"web3_id"`
	TweetUsrId    string   `json:"twitter_id" firestore:"twitter_id"`
	TweetId       string   `json:"tweet_id,omitempty" firestore:"tweet_id"`
	Signature     string   `json:"signature,omitempty" firestore:"signature"`
	PrefixedHash  string   `json:"prefixed_hash" firestore:"prefixed_hash"`
	PaymentStatus TxStatus `json:"payment_status" firestore:"payment_status"`
}

func (*NinjaTweet) IsValid

func (nt *NinjaTweet) IsValid() bool

func (*NinjaTweet) String

func (nt *NinjaTweet) String() string

type NinjaUsrInfo

type NinjaUsrInfo struct {
	Address  string `json:"address" firestore:"address"`
	EthAddr  string `json:"eth_addr" firestore:"eth_addr"`
	CreateAt int64  `json:"create_at" firestore:"create_at"`
	TwID     string `json:"tw_id" firestore:"tw_id"`
	UpdateAt int64
}

func NJUsrInfoMust

func NJUsrInfoMust(data []byte) (*NinjaUsrInfo, error)

func (*NinjaUsrInfo) RawData

func (nu *NinjaUsrInfo) RawData() []byte

func (*NinjaUsrInfo) RefreshSession

func (nu *NinjaUsrInfo) RefreshSession()

func (*NinjaUsrInfo) String

func (nu *NinjaUsrInfo) String() string

type NjTweetStatus

type NjTweetStatus struct {
	CreateTime int64 `json:"create_time" firestore:"create_time"`
	VoteCount  int   `json:"vote_count" firestore:"vote_count"`
}

type Poll

type Poll struct {
	DurationMinutes int      `json:"duration_minutes,omitempty"`
	Options         []string `json:"options,omitempty"`
}

type Reply

type Reply struct {
	ExcludeReplyUserIDs []string `json:"exclude_reply_user_ids,omitempty"`
	InReplyToTweetID    string   `json:"in_reply_to_tweet_id,omitempty"`
}

type SessionManager

type SessionManager struct {
	// contains filtered or unexported fields
}

func SMInst

func SMInst() *SessionManager

func (*SessionManager) Del

func (*SessionManager) Get

func (sm *SessionManager) Get(key string, r *http.Request) (any, error)

func (*SessionManager) Set

func (sm *SessionManager) Set(r *http.Request, w http.ResponseWriter, key string, val any) error

type SignDataByEth

type SignDataByEth struct {
	Message   string `json:"message"`
	Signature string `json:"signature"`
	PayLoad   any    `json:"pay_load,omitempty"`
}

func (*SignDataByEth) ParseNinjaTweet

func (sp *SignDataByEth) ParseNinjaTweet() (*NinjaTweet, error)

func (*SignDataByEth) RawData

func (sp *SignDataByEth) RawData() string

type SignInObj

type SignInObj struct {
	EthAddr string `json:"eth_addr"`
	SignTim int64  `json:"sign_time"`
}

func MustSignInData

func MustSignInData(str string) *SignInObj

func (*SignInObj) String

func (so *SignInObj) String() string

type StatusQuery

type StatusQuery struct {
	CreateTime []int64 `json:"create_time"`
}

type SysConf

type SysConf struct {
	LogLevel string `json:"log_level"`
	LocalRun bool   `json:"local_run"`
	UrlHome  string `json:"url_home"`
	HttpPort string `json:"http_port"`
	*HttpConf
	*TwitterConf
	*FileStoreConf

	*BlockChainConf
	// contains filtered or unexported fields
}

func (*SysConf) GetNjProtocolAd

func (c *SysConf) GetNjProtocolAd(NjTwID int64) string

func (*SysConf) String

func (c *SysConf) String() any

type TWUserInfo

type TWUserInfo struct {
	ID                   string `json:"id" firestore:"id"`
	Name                 string `json:"name" firestore:"name"`
	ScreenName           string `json:"username" firestore:"username"`
	Description          string `json:"description" firestore:"description"`
	ProfileImageUrlHttps string `json:"profile_image_url" firestore:"profile_image_url"`
	Verified             bool   `json:"verified"  firestore:"verified"`
}

func (*TWUserInfo) RawData

func (t *TWUserInfo) RawData() []byte

func (*TWUserInfo) String

func (t *TWUserInfo) String() string

type TwAPIResponse

type TwAPIResponse struct {
	TwitterData *TWUserInfo `json:"data"`
	EthAddr     string      `json:"eth_addr"`
	SignUpAt    int64       `json:"sign_up_at"`
}

type TwUserAccessToken

type TwUserAccessToken struct {
	OauthToken       string `json:"oauth_token" firestore:"oauth_token"`
	OauthTokenSecret string `json:"oauth_token_secret" firestore:"oauth_token_secret"`
	UserId           string `json:"user_id" firestore:"user_id"`
	ScreenName       string `json:"screen_name" firestore:"screen_name"`
}

func (*TwUserAccessToken) GetToken

func (ut *TwUserAccessToken) GetToken() *oauth1.Token

func (*TwUserAccessToken) String

func (ut *TwUserAccessToken) String() string

type TwUserAccessTokenV2

type TwUserAccessTokenV2 struct {
	UserId string `json:"user_id" firestore:"user_id"`
	*oauth2.Token
}

type TweetPaymentStatus

type TweetPaymentStatus struct {
	CreateTime int64    `json:"create_time"`
	Status     TxStatus `json:"status"`
}

type TweetPostResult

type TweetPostResult struct {
	ID   string `json:"id"`
	Text string `json:"text"`
}

type TweetRequest

type TweetRequest struct {
	Text                  string `json:"text,omitempty"`
	DirectMessageDeepLink string `json:"direct_message_deep_link,omitempty"`
	ForSuperFollowersOnly bool   `json:"for_super_followers_only,omitempty"`
	Geo                   *Geo   `json:"geo,omitempty"`
	Media                 *Media `json:"media,omitempty"`
	Poll                  *Poll  `json:"poll,omitempty"`
	QuoteTweetID          string `json:"quote_tweet_id,omitempty"`
	Reply                 *Reply `json:"reply,omitempty"`
	ReplySettings         string `json:"reply_settings,omitempty"`
}

type TweetResponse

type TweetResponse struct {
	Data TweetPostResult `json:"data"`
}

type TweetVoteAction

type TweetVoteAction struct {
	CreateTime int64 `json:"create_time"`
	VoteCount  int   `json:"vote_count"`
}

type TweetsOfUser

type TweetsOfUser struct {
	Tweets map[string]struct{} `json:"tweets"  firestore:"tweets"`
}

type TwitterConf

type TwitterConf struct {
	FontSize       float64 `json:"font_size"`
	FontPath       string  `json:"font_path"`
	MaxTxtPerImg   int     `json:"max_txt_per_img"`
	ClientID       string  `json:"client_id"`
	ClientSecret   string  `json:"client_secret"`
	ConsumerKey    string  `json:"consumer_key"`
	ConsumerSecret string  `json:"consumer_secret"`
	// contains filtered or unexported fields
}

func (*TwitterConf) String

func (c *TwitterConf) String() string

type TxStatus

type TxStatus int8
const (
	TxStNotPay TxStatus = iota
	TxStPending
	TxStSuccess
	TxStFailed
)

func (TxStatus) String

func (ts TxStatus) String() string

type VerifiedTwitterUser

type VerifiedTwitterUser struct {
	ContributorsEnabled            bool   `json:"contributors_enabled"`
	CreatedAt                      string `json:"created_at"`
	DefaultProfile                 bool   `json:"default_profile"`
	DefaultProfileImage            bool   `json:"default_profile_image"`
	Description                    string `json:"description"`
	FavouritesCount                int    `json:"favourites_count"`
	FollowersCount                 int    `json:"followers_count"`
	FriendsCount                   int    `json:"friends_count"`
	GeoEnabled                     bool   `json:"geo_enabled"`
	ID                             int64  `json:"id"`
	IDStr                          string `json:"id_str"`
	IsTranslator                   bool   `json:"is_translator"`
	Lang                           string `json:"lang"`
	ListedCount                    int    `json:"listed_count"`
	Location                       string `json:"location"`
	Name                           string `json:"name"`
	ProfileBackgroundColor         string `json:"profile_background_color"`
	ProfileBackgroundImageUrl      string `json:"profile_background_image_url"`
	ProfileBackgroundImageUrlHttps string `json:"profile_background_image_url_https"`
	ProfileBackgroundTile          bool   `json:"profile_background_tile"`
	ProfileImageUrl                string `json:"profile_image_url"`
	ProfileImageUrlHttps           string `json:"profile_image_url_https"`
	ProfileLinkColor               string `json:"profile_link_color"`
	ProfileSidebarBorderColor      string `json:"profile_sidebar_border_color"`
	ProfileSidebarFillColor        string `json:"profile_sidebar_fill_color"`
	ProfileTextColor               string `json:"profile_text_color"`
	ProfileUseBackgroundImage      bool   `json:"profile_use_background_image"`
	Protected                      bool   `json:"protected"`
	ScreenName                     string `json:"screen_name"`
	ShowAllInlineMedia             bool   `json:"show_all_inline_media"`
	StatusesCount                  int    `json:"statuses_count"`
	TimeZone                       string `json:"time_zone"`
	URL                            string `json:"url"`
	UtcOffset                      int    `json:"utc_offset"`
	Verified                       bool   `json:"verified"`
}

type Web3Binding

type Web3Binding struct {
	TwitterID string `json:"twitter_id" firestore:"twitter_id"`
	EthAddr   string `json:"eth_addr" firestore:"eth_addr"`
	SignUpAt  int64  `json:"sign_up_at" firestore:"sign_up_at"`
	Signature string `json:"signature" firestore:"signature"`
}

type Web3BindingData

type Web3BindingData struct {
	EthAddr  string `json:"eth_addr"`
	TwID     string `json:"tw_id"`
	BindTime int64  `json:"bind_time"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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