Documentation ¶
Index ¶
- Constants
- Variables
- type Authentication
- type Census
- type CensusCollection
- type Collection
- type CommunitiesCollection
- type Community
- type CommunityCensus
- type CommunityCensusAddresses
- type Election
- type ElectionCollection
- type ElectionCommunity
- type ElectionMeta
- type ElectionRanking
- type MongoStorage
- func (ms *MongoStorage) AddAuthentication(userFID uint64, authToken string) error
- func (ms *MongoStorage) AddCensus(censusID types.HexBytes, userFID uint64) error
- func (ms *MongoStorage) AddCommunity(id uint64, name, imageUrl, groupChatUrl string, census CommunityCensus, ...) error
- func (ms *MongoStorage) AddElection(electionID types.HexBytes, userFID uint64, source string, question string, ...) error
- func (ms *MongoStorage) AddElectionCallback(f funcGetElection)
- func (ms *MongoStorage) AddFinalResults(electionID types.HexBytes, finalPNG []byte, choices, votes []string) error
- func (ms *MongoStorage) AddNotificationMutedUser(ownerUserID, mutedUserID uint64) error
- func (ms *MongoStorage) AddNotifications(nType NotificationType, electionID string, ...) (int64, error)
- func (ms *MongoStorage) AddParticipantsToCensus(censusID types.HexBytes, participants map[string]*big.Int, ...) error
- func (ms *MongoStorage) AddUser(userFID uint64, usernanme string, displayname string, addresses []string, ...) error
- func (ms *MongoStorage) Authentications() ([]string, error)
- func (ms *MongoStorage) Census(censusID types.HexBytes) (Census, error)
- func (ms *MongoStorage) CensusFromElection(electionID types.HexBytes) (*Census, error)
- func (ms *MongoStorage) CensusFromRoot(root types.HexBytes) (*Census, error)
- func (ms *MongoStorage) Community(id uint64) (*Community, error)
- func (ms *MongoStorage) CommunityAllowNotifications(communityID uint64) bool
- func (ms *MongoStorage) CountUsers() uint64
- func (ms *MongoStorage) DelCommunity(communityID uint64) error
- func (ms *MongoStorage) DelNotificationMutedUser(ownerUserID, unmutedUserID uint64) error
- func (ms *MongoStorage) DelUser(userFID uint64) error
- func (ms *MongoStorage) Election(electionID types.HexBytes) (*Election, error)
- func (ms *MongoStorage) ElectionsByCommunity(communityID uint64) ([]*Election, error)
- func (ms *MongoStorage) ElectionsByUser(userFID uint64, count int64) ([]ElectionRanking, error)
- func (ms *MongoStorage) ElectionsByVoteNumber() ([]ElectionRanking, error)
- func (ms *MongoStorage) ElectionsWithoutResults() ([]string, error)
- func (ms *MongoStorage) FinalResultsPNG(electionID types.HexBytes) []byte
- func (ms *MongoStorage) Import(jsonData []byte) error
- func (ms *MongoStorage) IncreaseVoteCount(userFID uint64, electionID types.HexBytes, weight *big.Int) error
- func (ms *MongoStorage) IsCommunityAdmin(userID, communityID uint64) bool
- func (ms *MongoStorage) IsCommunityDisabled(communityID uint64) bool
- func (ms *MongoStorage) IsUserNotificationMuted(ownerUserID, mutedUserID uint64) (bool, error)
- func (ms *MongoStorage) LastCreatedElections(count int) ([]*Election, error)
- func (ms *MongoStorage) LastNotifications(maxResults int) ([]Notification, error)
- func (ms *MongoStorage) ListCommunities() ([]Community, error)
- func (ms *MongoStorage) ListCommunitiesByAdminFID(fid uint64) ([]Community, error)
- func (ms *MongoStorage) ListCommunitiesByAdminUsername(username string) ([]Community, error)
- func (ms *MongoStorage) ListNotificationMutedUsers(ownerUserID uint64) ([]*User, error)
- func (ms *MongoStorage) NextCommunityID() (uint64, error)
- func (ms *MongoStorage) RemoveNotification(notificationID int64) error
- func (ms *MongoStorage) Reset() error
- func (ms *MongoStorage) Results(electionID types.HexBytes) (*Results, error)
- func (ms *MongoStorage) SetAccessLevelForUser(userID uint64, accessLevel uint32) error
- func (ms *MongoStorage) SetCommunityNotifications(communityID uint64, enabled bool) error
- func (ms *MongoStorage) SetCommunityStatus(communityID uint64, disabled bool) error
- func (ms *MongoStorage) SetElectionIdForCensusRoot(root, electionID types.HexBytes) error
- func (ms *MongoStorage) SetNotificationDeadline(notificationID int64, deadline time.Time) error
- func (ms *MongoStorage) SetNotificationsAcceptedForUser(userID uint64, accepted bool) error
- func (ms *MongoStorage) SetNotificationsRequestedForUser(userID uint64, requested bool) error
- func (ms *MongoStorage) SetPartialResults(electionID types.HexBytes, choices, votes []string) error
- func (ms *MongoStorage) SetReputationForUser(userID uint64, reputation uint32) error
- func (ms *MongoStorage) SetRootForCensus(censusID, root types.HexBytes) error
- func (ms *MongoStorage) SetWhiteListedForUser(userID uint64, whiteListed bool) error
- func (ms *MongoStorage) String() string
- func (ms *MongoStorage) UpdateActivityAndGetData(authToken string) (*Authentication, error)
- func (ms *MongoStorage) UpdateAndGetReputationForUser(userID uint64) (uint32, *UserData, error)
- func (ms *MongoStorage) UpdateUser(udata *User) error
- func (ms *MongoStorage) User(userFID uint64) (*User, error)
- func (ms *MongoStorage) UserAccessProfile(userID uint64) (*UserAccessProfile, error)
- func (ms *MongoStorage) UserByAddress(address string) (*User, error)
- func (ms *MongoStorage) UserBySigner(signer string) (*User, error)
- func (ms *MongoStorage) UserByUsername(username string) (*User, error)
- func (ms *MongoStorage) UserExists(userFID uint64) bool
- func (ms *MongoStorage) UserFromAuthToken(authToken string) (uint64, error)
- func (ms *MongoStorage) UserIDs(startId uint64, maxResults int) ([]uint64, error)
- func (ms *MongoStorage) UsersByElectionNumber() ([]UserRanking, error)
- func (ms *MongoStorage) UsersByVoteNumber() ([]UserRanking, error)
- func (ms *MongoStorage) UsersWithPendingProfile() ([]uint64, error)
- func (ms *MongoStorage) VotersOfElection(electionID types.HexBytes) ([]*User, error)
- type Notification
- type NotificationType
- type Options
- type Results
- type ResultsCollection
- type User
- type UserAccessProfile
- type UserCollection
- type UserData
- type UserRanking
- type Users
- type VotersOfElection
- type VotersOfElectionCollection
Constants ¶
const ( // TypeCommunityCensusChannel is the type for a community census that uses // a channel as source. TypeCommunityCensusChannel = "channel" // TypeCommunityCensusERC20 is the type for a community census that uses // ERC20 holders as source. TypeCommunityCensusERC20 = "erc20" // TypeCommunityCensusNFT is the type for a community census that uses // NFT holders as source. TypeCommunityCensusNFT = "nft" )
Variables ¶
var ( ErrUserUnknown = fmt.Errorf("user unknown") ErrElectionUnknown = fmt.Errorf("electionID unknown") )
Functions ¶
This section is empty.
Types ¶
type Authentication ¶
type Authentication struct { UserID uint64 `json:"userId" bson:"_id"` AuthTokens []string `json:"authTokens" bson:"authTokens"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
Authentication represents the authentication data for a user.
type Census ¶
type Census struct { CensusID string `json:"censusId" bson:"_id"` Root string `json:"root" bson:"root"` ElectionID string `json:"electionId" bson:"electionId"` Participants map[string]string `json:"participants" bson:"participants"` FromTotalAddresses uint32 `json:"fromTotalAddresses" bson:"fromTotalAddresses"` CreatedBy uint64 `json:"createdBy" bson:"createdBy"` TotalWeight string `json:"totalWeight" bson:"totalWeight"` URL string `json:"url" bson:"url"` }
Census stores the census of an election ready to be used for voting on farcaster.
type CensusCollection ¶
type CensusCollection struct {
Censuses []Census `json:"censuses" bson:"censuses"`
}
CensusCollection is a dataset containing several censuses (used for dump and import).
type Collection ¶
type Collection struct { UserCollection ElectionCollection ResultsCollection VotersOfElectionCollection CensusCollection CommunitiesCollection }
Collection is a dataset containing several users, elections and results (used for dump and import).
type CommunitiesCollection ¶
type CommunitiesCollection struct {
Communities []Community `json:"communities" bson:"communities"`
}
CommunitiesCollection is a dataset containing several communities (used for dump and import).
type Community ¶
type Community struct { ID uint64 `json:"id" bson:"_id"` Name string `json:"name" bson:"name"` Channels []string `json:"channels" bson:"channels"` Census CommunityCensus `json:"census" bson:"census"` ImageURL string `json:"imageURL" bson:"imageURL"` GroupChatURL string `json:"groupChatURL" bson:"groupChatURL"` Admins []uint64 `json:"owners" bson:"owners"` Notifications bool `json:"notifications" bson:"notifications"` Disabled bool `json:"disabled" bson:"disabled"` }
Community represents a community entry.
type CommunityCensus ¶
type CommunityCensus struct { Name string `json:"name" bson:"name"` Type string `json:"type" bson:"type"` Addresses []CommunityCensusAddresses `json:"addresses" bson:"addresses"` Channel string `json:"channel" bson:"channel"` }
CommunityCensus represents the census of a community in the database. It includes the name, type, and the census addresses (CommunityCensusAddresses) or the census channel (depending on the type).
type CommunityCensusAddresses ¶
type CommunityCensusAddresses struct { Address string `json:"address" bson:"address"` Blockchain string `json:"blockchain" bson:"blockchain"` }
CommunityCensusAddresses represents the addresses of a contract to be used to create the census of a community.
type Election ¶
type Election struct { ElectionID string `json:"electionId" bson:"_id"` UserID uint64 `json:"userId" bson:"userId"` CastedVotes uint64 `json:"castedVotes" bson:"castedVotes"` LastVoteTime time.Time `json:"lastVoteTime" bson:"lastVoteTime"` CreatedTime time.Time `json:"createdTime" bson:"createdTime"` EndTime time.Time `json:"endTime" bson:"endTime"` Source string `json:"source" bson:"source"` FarcasterUserCount uint32 `json:"farcasterUserCount" bson:"farcasterUserCount"` InitialAddressesCount uint32 `json:"initialAddressesCount" bson:"initialAddressesCount"` Question string `json:"question" bson:"question"` Community *ElectionCommunity `json:"community" bson:"community"` CastedWeight string `json:"castedWeight" bson:"castedWeight"` }
Election represents an election and its details owned by a user.
type ElectionCollection ¶
type ElectionCollection struct {
Elections []Election `json:"elections" bson:"elections"`
}
ElectionCollection is a dataset containing several elections (used for dump and import).
type ElectionCommunity ¶
type ElectionCommunity struct { ID uint64 `json:"id" bson:"id"` Name string `json:"name" bson:"name"` }
ElectionCommunity represents the community used to create an election.
type ElectionMeta ¶
type ElectionMeta struct { // CensusERC20TokenDecimals is the number of decimals that a certain ERC20 token, that was used // for creating the census of the election, has. CensusERC20TokenDecimals uint32 `json:"censusERC20TokenDecimals" bson:"censusERC20TokenDecimals"` }
ElectionMeta stores non related election information that is useful for certain types of frame interactions
type ElectionRanking ¶
type ElectionRanking struct { ElectionID string `json:"electionId" bson:"_id"` VoteCount uint64 `json:"voteCount" bson:"voteCount"` CreatedByFID uint64 `json:"createdByFID" bson:"createdByFID"` CreatedByUsername string `json:"createdByUsername" bson:"createdByUsername"` CreatedByDisplayname string `json:"createdByDisplayname" bson:"createdByDisplayname"` Title string `json:"title" bson:"title"` }
ElectionRanking is an election ranking entry.
type MongoStorage ¶
type MongoStorage struct {
// contains filtered or unexported fields
}
MongoStorage uses an external MongoDB service for stoting the user data and election details.
func New ¶
func New(url, database string) (*MongoStorage, error)
func (*MongoStorage) AddAuthentication ¶
func (ms *MongoStorage) AddAuthentication(userFID uint64, authToken string) error
AddAuthentication adds an authentication token for a user and updates the CreatedAt field to the current time.
func (*MongoStorage) AddCensus ¶
func (ms *MongoStorage) AddCensus(censusID types.HexBytes, userFID uint64) error
AddCensus creates a new census document in the database.
func (*MongoStorage) AddCommunity ¶
func (ms *MongoStorage) AddCommunity(id uint64, name, imageUrl, groupChatUrl string, census CommunityCensus, channels []string, admins []uint64, notifications, disabled bool, ) error
func (*MongoStorage) AddElection ¶
func (*MongoStorage) AddElectionCallback ¶
func (ms *MongoStorage) AddElectionCallback(f funcGetElection)
AddElectionCallback adds a callback function to get the election details by its ID.
func (*MongoStorage) AddFinalResults ¶
func (ms *MongoStorage) AddFinalResults(electionID types.HexBytes, finalPNG []byte, choices, votes []string) error
AddFinalResults adds the final results of an election in PNG format. It performs and upsert operation, so it will update the results if they already exist.
func (*MongoStorage) AddNotificationMutedUser ¶
func (ms *MongoStorage) AddNotificationMutedUser(ownerUserID, mutedUserID uint64) error
AddNotificationMutedUser adds a user ID to the owner user's list of muted notifications users.
func (*MongoStorage) AddNotifications ¶
func (ms *MongoStorage) AddNotifications(nType NotificationType, electionID string, userID, authorID, communityID uint64, username, authorUsername, communityName, frameURL, customText string, deadline time.Time, ) (int64, error)
func (*MongoStorage) AddParticipantsToCensus ¶
func (ms *MongoStorage) AddParticipantsToCensus(censusID types.HexBytes, participants map[string]*big.Int, fromTotalAddresses uint32, totalWeight *big.Int, censusURI string, ) error
AddParticipantsToCensus updates a census document with participants and their associated values.
func (*MongoStorage) AddUser ¶
func (ms *MongoStorage) AddUser( userFID uint64, usernanme string, displayname string, addresses []string, signers []string, custodyAddr string, elections uint64, ) error
AddUser adds a new user to the database. If the user already exists, it returns an error.
func (*MongoStorage) Authentications ¶
func (ms *MongoStorage) Authentications() ([]string, error)
Authentications returns the full list of authTokens.
func (*MongoStorage) Census ¶
func (ms *MongoStorage) Census(censusID types.HexBytes) (Census, error)
Census retrieves a census document based on its ID.
func (*MongoStorage) CensusFromElection ¶
func (ms *MongoStorage) CensusFromElection(electionID types.HexBytes) (*Census, error)
CensusFromRoot retrieves a Census document by its root.
func (*MongoStorage) CensusFromRoot ¶
func (ms *MongoStorage) CensusFromRoot(root types.HexBytes) (*Census, error)
CensusFromRoot retrieves a Census document by its root.
func (*MongoStorage) CommunityAllowNotifications ¶
func (ms *MongoStorage) CommunityAllowNotifications(communityID uint64) bool
CommunityAllowNotifications checks if the community with the given ID has notifications enabled.
func (*MongoStorage) CountUsers ¶
func (ms *MongoStorage) CountUsers() uint64
CountUsers returns the total number of users in the database.
func (*MongoStorage) DelCommunity ¶
func (ms *MongoStorage) DelCommunity(communityID uint64) error
DelCommunity removes the community with the specified ID from the database. If an error occurs, it returns the error.
func (*MongoStorage) DelNotificationMutedUser ¶
func (ms *MongoStorage) DelNotificationMutedUser(ownerUserID, unmutedUserID uint64) error
DelNotificationMutedUser removes a user ID from the owner user's list of muted notifications users.
func (*MongoStorage) DelUser ¶
func (ms *MongoStorage) DelUser(userFID uint64) error
func (*MongoStorage) Election ¶
func (ms *MongoStorage) Election(electionID types.HexBytes) (*Election, error)
func (*MongoStorage) ElectionsByCommunity ¶
func (ms *MongoStorage) ElectionsByCommunity(communityID uint64) ([]*Election, error)
ElectionsByCommunity returns all the elections created by the community with the ID.
func (*MongoStorage) ElectionsByUser ¶
func (ms *MongoStorage) ElectionsByUser(userFID uint64, count int64) ([]ElectionRanking, error)
ElectionsByUser returns all the elections created by the user with the FID provided, sorted by CreatedTime in descending order.
func (*MongoStorage) ElectionsByVoteNumber ¶
func (ms *MongoStorage) ElectionsByVoteNumber() ([]ElectionRanking, error)
ElectionsByVoteNumber returns the list elections ordered by the number of votes casted.
func (*MongoStorage) ElectionsWithoutResults ¶
func (ms *MongoStorage) ElectionsWithoutResults() ([]string, error)
ElectionsWithoutResults returns a list of election IDs where results are not finalized or where the finalized field is not set.
func (*MongoStorage) FinalResultsPNG ¶
func (ms *MongoStorage) FinalResultsPNG(electionID types.HexBytes) []byte
FinalResultsPNG returns the final results of an election in PNG format. It returns nil if the results image is not found.
func (*MongoStorage) Import ¶
func (ms *MongoStorage) Import(jsonData []byte) error
Import imports a JSON dataset produced by String() into the database.
func (*MongoStorage) IncreaseVoteCount ¶
func (*MongoStorage) IsCommunityAdmin ¶
func (ms *MongoStorage) IsCommunityAdmin(userID, communityID uint64) bool
IsCommunityAdmin checks if the user is an admin of the given community by ID.
func (*MongoStorage) IsCommunityDisabled ¶
func (ms *MongoStorage) IsCommunityDisabled(communityID uint64) bool
IsCommunityDisabled checks if the community with the given ID is disabled.
func (*MongoStorage) IsUserNotificationMuted ¶
func (ms *MongoStorage) IsUserNotificationMuted(ownerUserID, mutedUserID uint64) (bool, error)
IsUserNotificationMuted checks if a user's notifications are muted by the owner user.
func (*MongoStorage) LastCreatedElections ¶
func (ms *MongoStorage) LastCreatedElections(count int) ([]*Election, error)
LastCreatedElections returns the last created elections.
func (*MongoStorage) LastNotifications ¶
func (ms *MongoStorage) LastNotifications(maxResults int) ([]Notification, error)
LastNotifications returns the registered notifications in the database ordered by the _id field in descending order and limited to the specified number of results. If an error occurs, it returns the error.
func (*MongoStorage) ListCommunities ¶
func (ms *MongoStorage) ListCommunities() ([]Community, error)
func (*MongoStorage) ListCommunitiesByAdminFID ¶
func (ms *MongoStorage) ListCommunitiesByAdminFID(fid uint64) ([]Community, error)
ListCommunitiesByAdminFID returns the list of communities where the user is an admin by FID provided.
func (*MongoStorage) ListCommunitiesByAdminUsername ¶
func (ms *MongoStorage) ListCommunitiesByAdminUsername(username string) ([]Community, error)
ListCommunitiesByAdminUsername returns the list of communities where the user is an admin by username provided. It queries about the user FID first.
func (*MongoStorage) ListNotificationMutedUsers ¶
func (ms *MongoStorage) ListNotificationMutedUsers(ownerUserID uint64) ([]*User, error)
ListNotificationMutedUsers returns a list of user IDs muted by the owner user.
func (*MongoStorage) NextCommunityID ¶
func (ms *MongoStorage) NextCommunityID() (uint64, error)
NextCommunityID returns the next community ID which will be assigned to a new community. It returns the last community ID + 1. If there are no communities in the database, it returns 0. If something goes wrong, it returns an error.
func (*MongoStorage) RemoveNotification ¶
func (ms *MongoStorage) RemoveNotification(notificationID int64) error
RemoveNotification removes the notification with the specified ID from the database. If an error occurs, it returns the error.
func (*MongoStorage) Reset ¶
func (ms *MongoStorage) Reset() error
func (*MongoStorage) Results ¶
func (ms *MongoStorage) Results(electionID types.HexBytes) (*Results, error)
Results retrieves the final results of an election.
func (*MongoStorage) SetAccessLevelForUser ¶
func (ms *MongoStorage) SetAccessLevelForUser(userID uint64, accessLevel uint32) error
SetAccessLevelForUser updates the access level for a given user ID.
func (*MongoStorage) SetCommunityNotifications ¶
func (ms *MongoStorage) SetCommunityNotifications(communityID uint64, enabled bool) error
SetCommunityNotifications sets the disabled status of the community with the given ID.
func (*MongoStorage) SetCommunityStatus ¶
func (ms *MongoStorage) SetCommunityStatus(communityID uint64, disabled bool) error
SetCommunityStatus sets the disabled status of the community with the given ID.
func (*MongoStorage) SetElectionIdForCensusRoot ¶
func (ms *MongoStorage) SetElectionIdForCensusRoot(root, electionID types.HexBytes) error
SetElectionIdForCensusRoot updates the ElectionID for a given census document by its root. If the root is not found, it returns nil, indicating no error occurred.
func (*MongoStorage) SetNotificationDeadline ¶
func (ms *MongoStorage) SetNotificationDeadline(notificationID int64, deadline time.Time) error
SetNotificationDeadline sets the deadline for the notification with the specified ID. If an error occurs, it returns the error.
func (*MongoStorage) SetNotificationsAcceptedForUser ¶
func (ms *MongoStorage) SetNotificationsAcceptedForUser(userID uint64, accepted bool) error
SetNotificationsAcceptedForUser updates the notifications accepted status for a given user ID.
func (*MongoStorage) SetNotificationsRequestedForUser ¶
func (ms *MongoStorage) SetNotificationsRequestedForUser(userID uint64, requested bool) error
SetNotificationsRequestedForUser updates the notifications requested status for a given user ID.
func (*MongoStorage) SetPartialResults ¶
func (ms *MongoStorage) SetPartialResults(electionID types.HexBytes, choices, votes []string) error
SetPartialResults sets or updates the choices and votes for an election result only if it is not finalized. It performs an upsert operation, so it will create the result entry if it does not exist and is not finalized.
func (*MongoStorage) SetReputationForUser ¶
func (ms *MongoStorage) SetReputationForUser(userID uint64, reputation uint32) error
SetReputationForUser updates the reputation for a given user ID.
func (*MongoStorage) SetRootForCensus ¶
func (ms *MongoStorage) SetRootForCensus(censusID, root types.HexBytes) error
SetRootForCensus updates the root for a given census document. If the census does not exist, it returns nil without error.
func (*MongoStorage) SetWhiteListedForUser ¶
func (ms *MongoStorage) SetWhiteListedForUser(userID uint64, whiteListed bool) error
SetWhiteListedForUser updates the white listed status for a given user ID.
func (*MongoStorage) String ¶
func (ms *MongoStorage) String() string
func (*MongoStorage) UpdateActivityAndGetData ¶
func (ms *MongoStorage) UpdateActivityAndGetData(authToken string) (*Authentication, error)
UpdateActivityAndGetData updates the activity timer and retrieves the Authentication data for a given authToken.
func (*MongoStorage) UpdateAndGetReputationForUser ¶
func (ms *MongoStorage) UpdateAndGetReputationForUser(userID uint64) (uint32, *UserData, error)
UpdateAndGetReputationForUser updates the user's reputation based on their activities and returns the new reputation.
func (*MongoStorage) UpdateUser ¶
func (ms *MongoStorage) UpdateUser(udata *User) error
func (*MongoStorage) UserAccessProfile ¶
func (ms *MongoStorage) UserAccessProfile(userID uint64) (*UserAccessProfile, error)
UserAccessProfile retrieves the access profile for a given user ID. Returns ErrUserUnknown if the user is not found.
func (*MongoStorage) UserByAddress ¶
func (ms *MongoStorage) UserByAddress(address string) (*User, error)
UserByAddress returns the user that has the given address. If the user is not found, it returns an error.
func (*MongoStorage) UserBySigner ¶
func (ms *MongoStorage) UserBySigner(signer string) (*User, error)
UserBySigner returns the user that has the given signer. If the user is not found, it returns an error.
func (*MongoStorage) UserByUsername ¶
func (ms *MongoStorage) UserByUsername(username string) (*User, error)
UserByUsername returns the user that has the given username. If the user is not found, it returns an error.
func (*MongoStorage) UserExists ¶
func (ms *MongoStorage) UserExists(userFID uint64) bool
func (*MongoStorage) UserFromAuthToken ¶
func (ms *MongoStorage) UserFromAuthToken(authToken string) (uint64, error)
CheckAuthentication checks if the authToken is valid and returns the corresponding userID. If the token is not found, it returns ErrUserUnknown.
func (*MongoStorage) UserIDs ¶
func (ms *MongoStorage) UserIDs(startId uint64, maxResults int) ([]uint64, error)
UserIDs returns a list of user IDs starting from the given ID and limited to the specified amount.
func (*MongoStorage) UsersByElectionNumber ¶
func (ms *MongoStorage) UsersByElectionNumber() ([]UserRanking, error)
UsersByElectionNumber returns the list of users ordered by the number of elections they have created.
func (*MongoStorage) UsersByVoteNumber ¶
func (ms *MongoStorage) UsersByVoteNumber() ([]UserRanking, error)
UsersByVoteNumber returns the list of users ordered by the number of votes they have casted.
func (*MongoStorage) UsersWithPendingProfile ¶
func (ms *MongoStorage) UsersWithPendingProfile() ([]uint64, error)
UsersWithPendingProfile returns the list of users that have not set their username yet. This call is limited to 32 users.
func (*MongoStorage) VotersOfElection ¶
func (ms *MongoStorage) VotersOfElection(electionID types.HexBytes) ([]*User, error)
VotersOfElection returns the list of voters of an election (usernames).
type Notification ¶
type Notification struct { ID int64 `json:"id" bson:"_id"` Type NotificationType `json:"type" bson:"type"` UserID uint64 `json:"userId" bson:"userId"` Username string `json:"username" bson:"username"` AuthorID uint64 `json:"authorId" bson:"authorId"` AuthorUsername string `json:"authorUsername" bson:"authorUsername"` CommunityID uint64 `json:"communityId" bson:"communityId"` CommunityName string `json:"communityName" bson:"communityName"` ElectionID string `json:"electionId" bson:"electionId"` FrameUrl string `json:"frameUrl" bson:"frameUrl"` CustomText string `json:"customText" bson:"customText"` Deadline time.Time `json:"deadline" bson:"deadline"` }
Notification represents a notification to be sent to a user.
type NotificationType ¶
type NotificationType int
NotificationType represents the type of notification to be sent to a user.
const (
NotificationTypeNewElection NotificationType = iota
)
type Results ¶
type Results struct { ElectionID string `json:"electionId" bson:"_id"` FinalPNG []byte `json:"finalPNG" bson:"finalPNG"` Choices []string `json:"title" bson:"title"` Votes []string `json:"votes" bson:"votes"` Finalized bool `json:"finalized" bson:"finalized"` }
Results represents the final results of an election.
type ResultsCollection ¶
type ResultsCollection struct {
Results []Results `json:"results" bson:"results"`
}
ResultsCollection is a dataset containing several election results (used for dump and import).
type User ¶
type User struct { UserID uint64 `json:"userID,omitempty" bson:"_id"` ElectionCount uint64 `json:"electionCount" bson:"electionCount"` CastedVotes uint64 `json:"castedVotes" bson:"castedVotes"` Username string `json:"username" bson:"username"` Displayname string `json:"displayname" bson:"displayname"` CustodyAddress string `json:"custodyAddress" bson:"custodyAddress"` Addresses []string `json:"addresses" bson:"addresses"` Signers []string `json:"signers" bson:"signers"` Followers uint64 `json:"followers" bson:"followers"` LastUpdated time.Time `json:"lastUpdated" bson:"lastUpdated"` Avatar string `json:"avatar" bson:"avatar"` }
User represents a farcaster user.
type UserAccessProfile ¶
type UserAccessProfile struct { UserID uint64 `json:"userID,omitempty" bson:"_id"` NotificationsAccepted bool `json:"notificationsAccepted" bson:"notificationsAccepted"` NotificationsRequested bool `json:"notificationsRequested" bson:"notificationsRequested"` Reputation uint32 `json:"reputation" bson:"reputation"` AccessLevel uint32 `json:"accessLevel" bson:"accessLevel"` WhiteListed bool `json:"whiteListed" bson:"whiteListed"` NotificationsMutedUsers []uint64 `json:"notificationsMutedUsers" bson:"notificationsMutedUsers"` }
UserAccessProfile holds the user's access profile data, used by our backend to determine the user's access level. It also holds the notification status.
type UserCollection ¶
type UserCollection struct {
Users []User `json:"users" bson:"users"`
}
UserCollection is a dataset containing several users (used for dump and import).
type UserData ¶
type UserData struct { FollowersCount uint64 `json:"followersCount"` ElectionsCreated uint64 `json:"electionsCreated"` CastedVotes uint64 `json:"castedVotes"` VotesCastedOnCreatedElections uint64 `json:"participationAchievement"` }
UserData holds the user's data for calculating reputation.
type UserRanking ¶
type UserRanking struct { FID uint64 `json:"fid" bson:"fid"` Username string `json:"username" bson:"username"` Displayname string `json:"displayname" bson:"displayname"` Count uint64 `json:"count" bson:"count"` }
UserRanking is a user ranking entry.
type VotersOfElection ¶
type VotersOfElection struct { ElectionID string `json:"electionId" bson:"_id"` Voters []uint64 `json:"voters" bson:"voters"` }
VotersOfElection represents the list of voters of an election.
type VotersOfElectionCollection ¶
type VotersOfElectionCollection struct {
VotersOfElection []VotersOfElection `json:"votersOfElection" bson:"votersOfElection"`
}
VotersOfElectionCollection is a dataset containing several voters of elections (used for dump and import).