db_controller

package
v0.0.0-...-f2a0a00 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateModifyRegisteredPushNotifications

func CreateModifyRegisteredPushNotifications(t NotificationTokens) error

func DeleteToken

func DeleteToken(did string, tokenUUID string) error

DeleteToken deletes a token using did and uuid

func DeleteTokenViaBasic

func DeleteTokenViaBasic(username string, password string) error

DeleteTokenViaBasic deletes a token using the username and password

func DeleteeeeeeeeeeeeRegistrationForPushNotifications

func DeleteeeeeeeeeeeeRegistrationForPushNotifications(token NotificationTokens) error

vs code decided to freeze at this point, and i think its funny so im keeping it.

func DeleteeeeeeeeeeeeRegistrationForPushNotificationsWithDid

func DeleteeeeeeeeeeeeRegistrationForPushNotificationsWithDid(did string) error

this should not be did but i am lazy

func DeleteeeeeeeeeeeeRegistrationForPushNotificationsWithRoutingInfo

func DeleteeeeeeeeeeeeRegistrationForPushNotificationsWithRoutingInfo(routing_key []byte, routing_server_address string) error

this should not be did but i am lazy

func GetOriginalURL

func GetOriginalURL(shortCode string) (string, error)

GetOriginalURL retrieves the original URL from the database using the short code

func GetToken

func GetToken(did string, tokenUUID string, encryptionKey string, tokenVersion int) (*string, *string, *float64, *float64, *string, error)

func GetTokenViaBasic

func GetTokenViaBasic(username string, password string) (*string, *string, *float64, *float64, *string, *string, *string, *string, *string, error)

GetTokenViaBasic retrieves a token using only the password @results: accessToken, refreshToken, accessExpiry, refreshExpiry, pds, did, hash, salt, uuid, error

func GetTwitterIDFromDatabase

func GetTwitterIDFromDatabase(twitterID *int64) (*string, *time.Time, *string, error)

Gets a twitter id from the database @params: twitterID @results: blueskyID, dateCreated, reposterDid, error

func InitDB

func InitDB(_cfg config.Config)

func SaveRegistrationForPushNotifications

func SaveRegistrationForPushNotifications(token NotificationTokens) error

func StartPeriodicAnalyticsWriter

func StartPeriodicAnalyticsWriter(interval time.Duration)

func StoreAnalyticData

func StoreAnalyticData(data AnalyticData)

Stores analytic data (if enabled) -- TYPES -- 1. "login" 2. "tweets viewed" 3. "tweets posted"

func StoreShortLink(shortCode string, originalURL string) error

StoreShortLink stores a short link in the database with optimized collision handling

func StoreToken

func StoreToken(did string, pds string, accessToken string, refreshToken string, encryptionKey string, accessExpiry float64, refreshExpiry float64) (*string, error)

StoreToken stores an encrypted access token and refresh token in the database. It returns the UUID of the stored token or an error if the operation fails.

Parameters: - did: The decentralized identifier of the user. - accessToken: The access token to be encrypted and stored. - refreshToken: The refresh token to be encrypted and stored. - encryptionKey: The key used to encrypt the tokens. - accessExpiry: The expiry time of the access token. - refreshExpiry: The expiry time of the refresh token.

Returns: - The UUID of the stored token. - An error if the operation fails.

func StoreTokenBasic

func StoreTokenBasic(did string, pds string, accessToken string, refreshToken string, username string, password string, accessExpiry float64, refreshExpiry float64) (*string, error)

StoreTokenBasic stores a token using basic auth (password)

func StoreTwitterIdInDatabase

func StoreTwitterIdInDatabase(twitterID *int64, blueskyId string, dateCreated *time.Time, reposterDid *string) error

Stores ID data in the database. @params: twitterID, blueskyID, dateCreated, reposterDid @results: error

func UpdateToken

func UpdateToken(uuid string, did string, pds string, accessToken string, refreshToken string, encryptionKey string, accessExpiry float64, refreshExpiry float64, tokenVersion int) (*string, error)

func UpdateTokenBasic

func UpdateTokenBasic(did string, pds string, accessToken string, refreshToken string, accessExpiry float64, refreshExpiry float64, username string, password string, passwordHash string, passwordSalt string, uuid string) (*string, error)

UpdateTokenBasic updates or creates a token entry using basic auth

func WriteAnalyticsToDB

func WriteAnalyticsToDB()

Types

type AnalyticData

type AnalyticData struct {
	DataType             string    `gorm:"type:string;not null"`
	IPAddress            string    `gorm:"type:string;"`
	Language             string    `gorm:"type:string;"`
	UserAgent            string    `gorm:"type:string;"`
	TwitterClient        string    `gorm:"type:string"`
	TwitterClientVersion string    `gorm:"type:string"`
	Timestamp            time.Time `gorm:"type:timestamp"`
}

type MessageContext

type MessageContext struct {
	UserDid         string `gorm:"type:string;primaryKey;not null"`
	TokenUUID       string `gorm:"type:string;primaryKey;not null"`
	LastMessageId   string `gorm:"type:string;not null"`
	TimelineContext string `gorm:"type:string;not null"`
}

type NotificationTokens

type NotificationTokens struct {
	DeviceToken   []byte
	RoutingKey    []byte
	ServerAddress string
	UserDID       string `gorm:"column:user_did;primaryKey"`
	EnabledFor    int
	LastUpdated   time.Time
}

func GetAllActivePushNotifications

func GetAllActivePushNotifications() ([]NotificationTokens, error)

func GetPushTokensForDID

func GetPushTokensForDID(did string) ([]NotificationTokens, error)
type ShortLink struct {
	ShortCode   string `gorm:"type:string;primaryKey;not null"`
	OriginalURL string `gorm:"type:string;not null"`
}

ShortLink represents the schema for the short_links table

type Token

type Token struct {
	BasicAuthHash         string  `gorm:"type:string;"`      // I am not a fan that i have to store this for basic authentication
	BasicAuthUsername     string  `gorm:"type:string;index"` // Add this field with an index
	UserDid               string  `gorm:"type:string;index;not null"`
	UserPDS               string  `gorm:"type:string;not null"`
	TokenUUID             string  `gorm:"type:string;primaryKey"`
	EncryptedAccessToken  string  `gorm:"type:string;not null"`
	EncryptedRefreshToken string  `gorm:"type:string;not null"`
	AccessExpiry          float64 `gorm:"type:float;not null"`
	RefreshExpiry         float64 `gorm:"type:float;not null"`
	BasicAuthSalt         string  `gorm:"type:string"`
	TokenVersion          int     `gorm:"type:int;default:1"`
}

Token represents the schema for the tokens table

type TwitterIDs

type TwitterIDs struct {
	BlueskyID   string     `gorm:"type:string;not null"`
	TwitterID   string     `gorm:"type:string;primaryKey;not null"`
	ReposterDid *string    `gorm:"type:string"`
	DateCreated *time.Time `gorm:"type:timestamp"`
}

Jump to

Keyboard shortcuts

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