postgres

package
v0.0.0-...-a352208 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const OTP_EXPIRY_MINUTES = 20
View Source
const OTP_MAX_RETRIES = 3

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresDB

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

func NewPostgresDB

func NewPostgresDB() (*PostgresDB, error)

func (*PostgresDB) AddSPGroup

func (db *PostgresDB) AddSPGroup(group *models.SpGroup, writer string) (*models.SpGroup, error)

func (*PostgresDB) AddSPUserToGroup

func (db *PostgresDB) AddSPUserToGroup(
	spGroupUser *models.SpGroupUser, writer string) (*models.SpGroupUser, error)

func (*PostgresDB) AddSpMessage

func (db *PostgresDB) AddSpMessage(
	msg *models.SpMessage, tz, writer string) (*models.SpGroupMsgData, error)

func (*PostgresDB) AddTweetToThread

func (db *PostgresDB) AddTweetToThread(userID, tweetID, threadID, writer string) error

func (*PostgresDB) CheckOTP

func (db *PostgresDB) CheckOTP(
	phone, code string,
	now time.Time, writer string) (*models.SpOtp, error)

func (*PostgresDB) CreateInvalidToken

func (db *PostgresDB) CreateInvalidToken(it *models.InvalidToken) error

func (*PostgresDB) CreateOTP

func (db *PostgresDB) CreateOTP(phone string, now time.Time, writer string) error

func (*PostgresDB) CreateThread

func (db *PostgresDB) CreateThread(userID, name, writer string) (*models.Thread, error)

func (*PostgresDB) CreateTwitterChallenge

func (db *PostgresDB) CreateTwitterChallenge(token, redirectURI, writer string) (string, error)

func (*PostgresDB) CreateUser

func (db *PostgresDB) CreateUser(u *models.User) error

func (*PostgresDB) DelTweetFromThread

func (db *PostgresDB) DelTweetFromThread(userID, tweetID, threadID, writer string) error

func (*PostgresDB) Delete

func (db *PostgresDB) Delete(table string, writer string) error

Delete deletes all entries in a table of a writer ONLY USE IN TESTS

func (*PostgresDB) DeleteAllOTPs

func (db *PostgresDB) DeleteAllOTPs(writer string) error

func (*PostgresDB) DeleteGuestData

func (db *PostgresDB) DeleteGuestData(
	userID string,
	maxTweets int,
	writer string) error

DeleteGuestData delete tweets if number of tweets > maxTweets Delete oldest ones first. Will not touch tags

func (*PostgresDB) DeleteOldOneTimes

func (db *PostgresDB) DeleteOldOneTimes(expiry time.Duration, writer string) error

func (*PostgresDB) DeleteOldTwitterChallenges

func (db *PostgresDB) DeleteOldTwitterChallenges(checkpoint time.Duration)

func (*PostgresDB) DeleteThread

func (db *PostgresDB) DeleteThread(userID, threadID, writer string) (*models.Thread, error)

func (*PostgresDB) DeleteTweet

func (db *PostgresDB) DeleteTweet(userID, tweetID, writer string) (*models.Tweet, error)

func (*PostgresDB) ExpireOTPs

func (db *PostgresDB) ExpireOTPs(now time.Time, writer string) error

func (*PostgresDB) FindOrCreateSPUser

func (db *PostgresDB) FindOrCreateSPUser(
	phone string, writer string) (*models.SpUser, error)

func (*PostgresDB) FindOrCreateUser

func (db *PostgresDB) FindOrCreateUser(u *models.User) (*models.User, error)

func (*PostgresDB) GetAllTweets

func (db *PostgresDB) GetAllTweets(writer string, offset int, count int) ([]*models.Tweet, int, error)

func (*PostgresDB) GetOTP

func (db *PostgresDB) GetOTP(phone, writer string) (*models.SpOtp, error)

func (*PostgresDB) GetOneTime

func (db *PostgresDB) GetOneTime(
	id string, expiry time.Duration, writer string) (*models.Onetime, error)

GetOneTime Returns a one time value if it hasn't expired

func (*PostgresDB) GetRawTweet

func (db *PostgresDB) GetRawTweet(userID, tweetID, writer string) (*models.Tweet, error)

GetRawTweet Ignore the delete flag and return deleted flags.

func (*PostgresDB) GetResources

func (db *PostgresDB) GetResources(userID, writer string) ([]*models.Resource, error)

func (*PostgresDB) GetSPGroupMessagesByDay

func (db *PostgresDB) GetSPGroupMessagesByDay(
	groupID string, start time.Time, tz string, limit int,
	writer string) ([]*models.SpGroupMsgData, error)

func (*PostgresDB) GetSPGroupUser

func (db *PostgresDB) GetSPGroupUser(
	userID, groupID, writer string) (*models.SpGroupUser, error)

func (*PostgresDB) GetSPGroupUsers

func (db *PostgresDB) GetSPGroupUsers(
	groupID, writer string) ([]*models.SpUser, error)

GetSPGroupUsers user.Role is overwritten to the role in the group

func (*PostgresDB) GetSPGroupsForUser

func (db *PostgresDB) GetSPGroupsForUser(userID, writer string) ([]*models.SpGroupSend, error)

func (*PostgresDB) GetSPServices

func (db *PostgresDB) GetSPServices(writer string) ([]*models.SpService, error)

func (*PostgresDB) GetSPUserByID

func (db *PostgresDB) GetSPUserByID(id string, writer string) (*models.SpUser, error)

func (*PostgresDB) GetSPUserMessagesByDay

func (db *PostgresDB) GetSPUserMessagesByDay(userID string, start time.Time, tz string, limit int,
	writer string) ([]*models.SpGroupMsgData, error)

func (*PostgresDB) GetTags

func (db *PostgresDB) GetTags(userID, writer string) ([]*models.Tag, error)

func (*PostgresDB) GetThread

func (db *PostgresDB) GetThread(userID, threadID, writer string) (*models.ThreadData, error)

func (*PostgresDB) GetThreadTweets

func (db *PostgresDB) GetThreadTweets(
	userID, threadID, writer string) ([]*models.ThreadTweet, error)

func (*PostgresDB) GetTweet

func (db *PostgresDB) GetTweet(userID, tweetID, writer string) (*models.Tweet, error)

func (*PostgresDB) GetTweetTags

func (db *PostgresDB) GetTweetTags(userID, tweetID, writer string) ([]*models.Tag, error)

func (*PostgresDB) GetTweets

func (db *PostgresDB) GetTweets(userID string,
	offset, limit int,
	reverse bool,
	writer string,
) ([]*models.Tweet, error)

func (*PostgresDB) GetTwitterChallenge

func (db *PostgresDB) GetTwitterChallenge(token, writer string) (string, string, error)

func (*PostgresDB) GetUser

func (db *PostgresDB) GetUser(userID string, writer string) (*models.User, error)

func (*PostgresDB) GetUserByHandle

func (db *PostgresDB) GetUserByHandle(username, writer string) (*models.User, error)

func (*PostgresDB) InsertTweet

func (db *PostgresDB) InsertTweet(
	tweet *models.Tweet,
	tags []*models.Tag,
	threads []*utils.ThreadDetails,
) (*models.Tweet, []*models.Tag, error)

InsertTweet Inserts the tweet and all the tags and creates the necessary tweet tags as well.

func (*PostgresDB) IsInvalidToken

func (db *PostgresDB) IsInvalidToken(token string, writer string) (bool, error)

func (*PostgresDB) LockResource

func (db *PostgresDB) LockResource(req *models.Resource) (*models.Resource, error)

func (*PostgresDB) SaveOneTime

func (db *PostgresDB) SaveOneTime(onetime *models.Onetime) error

func (*PostgresDB) SearchTweetsByTags

func (db *PostgresDB) SearchTweetsByTags(userID string,
	tags []string, offset, limit int, reverse bool, writer string) ([]*models.Tweet, error)

func (*PostgresDB) SetOneTime

func (db *PostgresDB) SetOneTime(val, writer string) (*models.Onetime, error)

SetOneTime Creates a new onetime table record.

func (*PostgresDB) SetResources

func (db *PostgresDB) SetResources(
	req *models.Resource, value int, writer string) (*models.Resource, error)

func (*PostgresDB) UnlockResource

func (db *PostgresDB) UnlockResource(req *models.Resource) (*models.Resource, error)

func (*PostgresDB) UpdateSPUser

func (db *PostgresDB) UpdateSPUser(user *models.SpUser) (*models.SpUser, error)

func (*PostgresDB) UpdateTweet

func (db *PostgresDB) UpdateTweet(
	tweet *models.Tweet,
	tags []*models.Tag,
	threads []*utils.ThreadDetails,
	writer string,
) (*models.Tweet, []*models.Tag, error)

Jump to

Keyboard shortcuts

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