friendships

package
v0.0.0-...-6dfde0d Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2017 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFriendSelf = errors.New("You cannot friend yourself. Being friends with yourself is weird. Go be friends with other people.")
)

Functions

func Exists

func Exists(userID, friendID string, db *gorm.DB) bool

func GetIDsByUserID

func GetIDsByUserID(userID string, db *gorm.DB) (uuids []string, err error)

func ListConfirmedIDsByUserID

func ListConfirmedIDsByUserID(userID string, db *gorm.DB) (uuids []string, err error)

func TestValidation

func TestValidation(t *testing.T)

Types

type CreatorBinding

type CreatorBinding struct {
	FriendID string `json:"friend_id" binding:"required"`
}

type Friendship

type Friendship struct {
	ID        string     `json:"id" gorm:"primary_key" sql:"type:uuid;default:uuid_generate_v4()"`
	UserID    string     `json:"user_id" sql:"type:uuid"`   // ID of first user
	FriendID  string     `json:"friend_id" sql:"type:uuid"` // ID of second user
	Friend    users.User `json:"user" sql:"-"`
	Match     float64    `json:"match" sql:"-"`
	Confirmed bool       `json:"confirmed"` // Whether the second user has confirmed
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
}

Friendship is a joining table between two users who are friends. For each friendship there are two Friendship records: one for each user

func GetByUserIDs

func GetByUserIDs(userID, friendID string, db *gorm.DB) (f Friendship, err error)

func New

func New(userID string, b CreatorBinding) (f Friendship, errs models.ValidationErrors)

func (Friendship) CanDelete

func (f Friendship) CanDelete(userID string) bool

func (Friendship) GetAction

func (f Friendship) GetAction() string

func (Friendship) GetID

func (f Friendship) GetID() string

func (Friendship) GetNotifType

func (f Friendship) GetNotifType() string

func (*Friendship) Update

func (Friendship) Validate

func (f Friendship) Validate() (errs models.ValidationErrors)

type Friendships

type Friendships []Friendship

func GetConfirmedByUserID

func GetConfirmedByUserID(userID string, db *gorm.DB) (fs Friendships, err error)

func ListByUserID

func ListByUserID(userID string, db *gorm.DB) (fs Friendships, err error)

func ListConfirmedByUserID

func ListConfirmedByUserID(userID string, db *gorm.DB) (fs Friendships, err error)

type UpdaterBinding

type UpdaterBinding struct {
	Confirmed bool `json:"confirmed" binding:"required"`
}

Jump to

Keyboard shortcuts

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