repo

package
v0.0.0-...-fce496f Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GuestHubDistance = 1_000_000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectedMessageHub

type ConnectedMessageHub struct {
	Hub         MessageHub
	MinDistance int
	Count       int
}

type FCMToken

type FCMToken struct {
	UserID    string    `db:"user_id"`
	Token     string    `db:"token"`
	DeviceID  string    `db:"device_id"`
	CreatedAt time.Time `db:"created_at"`
}

type FCMTokenRepo

type FCMTokenRepo interface {
	AddToken(userID, token, deviceID, os string)
	UsersTokens(userIDs []string) []string
	DeleteUserTokens(tx *sqlx.Tx, userID string)
}

func NewFCMToken

func NewFCMToken(db *sqlx.DB) FCMTokenRepo

type FriendRepo

type FriendRepo interface {
	Friends(user User) []User
	FriendsWithSubFriends(user User) map[User][]User
	FriendsOfFriends(user User) map[User][]User
	AreFriends(userID1, userID2 string) bool
	DeleteUserFriends(tx *sqlx.Tx, userID string)
}

func NewFriends

func NewFriends(db *sqlx.DB) FriendRepo

type Group

type Group struct {
	ID                string    `json:"id" db:"id"`
	Name              string    `json:"name" db:"name"`
	Description       string    `json:"description" db:"description"`
	AdminID           string    `json:"admin_id" db:"admin_id"`
	AvatarOriginalID  string    `json:"avatar_original_id,omitempty" db:"avatar_original_id"`
	AvatarThumbnailID string    `json:"avatar_thumbnail_id,omitempty" db:"avatar_thumbnail_id"`
	IsPublic          bool      `json:"is_public" db:"is_public"`
	CreatedAt         time.Time `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt         time.Time `json:"updated_at,omitempty" db:"updated_at"`
	BackgroundID      string    `json:"background_id" db:"background_id"`
	MemberCount       int       `json:"member_count" db:"member_count"`
}

type GroupInvite

type GroupInvite struct {
	ID                int          `db:"id"`
	GroupID           string       `db:"group_id"`
	GroupName         string       `db:"group_name"`
	GroupDescription  string       `db:"group_description"`
	GroupIsPublic     bool         `db:"group_is_public"`
	InviterID         string       `db:"inviter_id"`
	InviterAvatarID   string       `db:"inviter_avatar_id"`
	InvitedID         string       `db:"invited_id"`
	InvitedEmail      string       `db:"invited_email"`
	InvitedAvatarID   string       `db:"invited_avatar_id"`
	CreatedAt         time.Time    `db:"created_at"`
	AcceptedAt        sql.NullTime `db:"accepted_at"`
	RejectedAt        sql.NullTime `db:"rejected_at"`
	AcceptedByAdminAt sql.NullTime `db:"accepted_by_admin_at"`
	RejectedByAdminAt sql.NullTime `db:"rejected_by_admin_at"`
	Message           string       `db:"message"`
}

type GroupRepo

type GroupRepo interface {
	FindGroupByIDOrName(value string) *Group
	FindGroupByID(id string) *Group
	FindGroupByName(name string) *Group
	AddGroup(id, name, description, adminID string, isPublic bool)
	SetAvatar(groupID, avatarOriginalID, avatarThumbnailID string)
	SetBackground(groupID, backgroundID string)
	SetDescription(groupID, description string)
	SetIsPublic(groupID string, isPublic bool)
	AddUserToGroup(groupID, userID string)
	DeleteGroup(groupID string)
	IsGroupMember(groupID, userID string) bool
	AddInvite(groupID, inviterID, invitedID, message string)
	DeleteInvite(groupID, inviterID, invitedID string)
	DeleteInvites(groupID, invitedID string)
	AddInviteByEmail(groupID, inviterID, invitedEmail, message string)
	AcceptInvite(groupID, inviterID, invitedID string) bool
	RejectInvite(groupID, inviterID, invitedID string) bool
	InvitesFromMe(user User) []GroupInvite
	InvitesForMe(user User) []GroupInvite
	RemoveUserFromGroup(groupID, userID string)
	GroupMembers(groupID string) []User
	ManagedGroups(adminID string) []Group
	ConfirmInvite(groupID, inviterID, invitedID string)
	DenyInvite(groupID, inviterID, invitedID string)
	AdminInvitesToConfirm(adminID string) []GroupInvite
	GroupInvitesToConfirm(groupID string) []GroupInvite
	PublicGroups() []Group
	JoinStatuses(userID string) map[string]string
	JoinStatus(userID, groupID string) string
	UserGroups(userID string) []Group
	UserGroupCount(userID string) int
	DeleteUserData(tx *sqlx.Tx, userID string)
}

func NewGroups

func NewGroups(db *sqlx.DB) GroupRepo

type Invite

type Invite struct {
	ID          int          `db:"id"`
	UserID      string       `db:"user_id"`
	FriendID    string       `db:"friend_id"`
	FriendEmail string       `db:"friend_email"`
	CreatedAt   time.Time    `db:"created_at"`
	AcceptedAt  sql.NullTime `db:"accepted_at"`
	RejectedAt  sql.NullTime `db:"rejected_at"`
}

type InviteRepo

type InviteRepo interface {
	AddInvite(userID, friendID string)
	AddInviteByEmail(userID, friendEmail string)
	AcceptInvite(inviterID, friendID string, autoAccepted bool) bool
	RejectInvite(inviterID, friendID string) bool
	InvitesFromMe(user User) []Invite
	OpenInvitesForMe(user User) []Invite
	InviteStatuses(user User) map[string]string
	DeleteUserInvites(tx *sqlx.Tx, userID string)
}

func NewInvites

func NewInvites(db *sqlx.DB) InviteRepo

type MessageHub

type MessageHub struct {
	ID                string       `db:"id"`
	Address           string       `db:"address"`
	AdminID           string       `db:"admin_id"`
	CreatedAt         time.Time    `db:"created_at"`
	ApprovedAt        sql.NullTime `db:"approved_at"`
	DisabledAt        sql.NullTime `db:"disabled_at"`
	Details           string       `db:"details"`
	PostLimit         int          `db:"post_limit"`
	AllowFriendGroups bool         `db:"allow_friend_groups"`
	ExpirationDays    int          `db:"expiration_days"`
}

type MessageHubRepo

type MessageHubRepo interface {
	HubExists(address string) bool
	AddHub(address, details string, hubAdminID string, postLimit int, allowFriendGroups bool) string
	AllHubs() []MessageHub
	Hubs(user User) []MessageHub
	HubByID(hubID string) *MessageHub
	HubByIDOrAddress(hubID string) *MessageHub
	ApproveHub(hubID string)
	RemoveHub(hubID string)
	ConnectedHubs(user User) []ConnectedMessageHub
	SetHubPostLimit(hubAdminID, hubID string, postLimit int)
	SetHubAllowFriendGroups(hubAdminID, hubID string, allowFriendGroups bool)
	SetHubExpirationDays(hubAdminID, hubID string, expirationDays int)
	AssignUserToHub(userID, hubID string, minDistance int)
	SetUserPublic(userID, hubID string, isPublic bool)
	UserHubs(userIDs []string, forPublicMessages bool) map[string][]string
	GroupHub(groupAdminID string) string
	BlockUser(userID, hubID string)
	DeleteUserData(tx *sqlx.Tx, userID string)
}

func NewMessageHubs

func NewMessageHubs(db *sqlx.DB) MessageHubRepo

type Repos

type Repos struct {
	User         UserRepo
	Invite       InviteRepo
	Friend       FriendRepo
	MessageHubs  MessageHubRepo
	Notification common.NotificationRepo
	FCMToken     FCMTokenRepo
	Setting      common.SettingRepo
	Group        GroupRepo
	// contains filtered or unexported fields
}

func NewRepos

func NewRepos(db *sqlx.DB) Repos

func (Repos) DeleteUserData

func (r Repos) DeleteUserData(userID string)

type User

type User struct {
	ID           string       `json:"id" db:"id"`
	PasswordHash string       `json:"-" db:"password_hash"`
	CreatedAt    time.Time    `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt    time.Time    `json:"updated_at,omitempty" db:"updated_at"`
	ConfirmedAt  sql.NullTime `json:"confirmed_at,omitempty" db:"confirmed_at"`
}

type UserRepo

type UserRepo interface {
	FindUserByIDOrName(value string) *User
	FindUserByID(id string) *User
	FindUsersByEmail(email string) []User
	FindUserByName(name string) *User
	AddUser(id, name, email, fullName, passwordHash string, hideIdentity bool)
	UserCount() int
	SetAvatar(userID, avatarOriginalID, avatarThumbnailID string)
	SetEmail(userID, email string)
	SetFullName(userID, fullName string)
	SetPassword(userID, passwordHash string)
	SetBackground(userID, backgroundID string)
	SetHideIdentity(userID string, hideIdentity bool)
	FindUsers(ids []string) []User
	ConfirmUser(userID string) bool
	BlockUser(userID, blockedUserID string)
	AreBlocked(userID1, userID2 string) bool
	BlockedUserIDs(userID string) []string
	UsersKey(userID1, userID2 string) []byte
	DeleteUser(tx *sqlx.Tx, userID string)
}

func NewUsers

func NewUsers(db *sqlx.DB) UserRepo

Jump to

Keyboard shortcuts

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