repository

package
v0.0.0-...-02ebfc9 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Database           = "cancanvas"
	CollectionUsers    = "users"
	CollectionChats    = "chats"
	CollectionPosts    = "posts"
	CollectionAuctions = "auctions"
	CollectionTags     = "tags"
	CollectionPayments = "payments"
)

Database and Collection names

View Source
const PageSize = 10

PageSize constant

Variables

This section is empty.

Functions

func GetHash

func GetHash(salt, password string) string

GetHash function

func GetSalt

func GetSalt() string

GetSalt function

Types

type AuctionRepository

type AuctionRepository interface {
	GetAuctions(page *int) ([]*model.FeedAuction, error)
	CreateAuction(sender, description string, offer float64) (*model.Auction, error)
	DeleteAuction(sender, auctionID string) (bool, error)
	CreateBid(sender, auctionID, deadline string, price float64) (*model.Bid, error)
	DeleteBid(sender, auctionID, bidID string) (bool, error)
	AcceptBid(sender, auctionID, bidID string) (bool, error)
	AcceptedBids(sender string) ([]*model.FeedAuction, error)
	BidPaymentLink(sender, auctionID, bidID string) (string, error)
}

AuctionRepository interface

func NewAuctionRepository

func NewAuctionRepository() AuctionRepository

NewAuctionRepository function

type AuthRepository

type AuthRepository interface {
	Login(username, password string) (*model.Login, error)
	ResetPassword(sender, hash, newPassword string) (bool, error)
	SendForgotPasswordEmail(user string) (bool, error)
}

AuthRepository interface

func NewAuthRepository

func NewAuthRepository() AuthRepository

NewAuthRepository function

type Chat

type Chat struct {
	ID       string    `json:"_id,omitempty" bson:"_id,omitempty"`
	Users    []string  `json:"users"`
	Messages []Message `json:"messages"`
}

Chat struct

type ChatRepository

type ChatRepository interface {
	SendMessage(sender, msg, receiver string) (bool, error)
	SendMessageToDialogflow(sender, msg string) (string, error)
	NewChatMessage(sender string) (<-chan *model.Message, error)
	// contains filtered or unexported methods
}

ChatRepository interface

func NewChatRepository

func NewChatRepository() ChatRepository

NewChatRepository function

type FeedRepository

type FeedRepository interface {
	GetFeed(nickname string, page *int) ([]*model.FeedPost, error)
	GetTrending(nickname string, page *int) ([]*model.FeedPost, error)
}

FeedRepository interface

func NewFeedRepository

func NewFeedRepository() FeedRepository

NewFeedRepository function

type Message

type Message struct {
	Message   string `json:"message"`
	Timestamp string `json:"timestamp"`
	Sender    string `json:"sender"`
}

Message struct

type OrderRepository

type OrderRepository interface {
	CreateOrder(auctionID, bidID, description string, price float64) (string, error)
	GetOrder(sender, orderID string) (*model.Order, error)
	GetOrders(sender string) ([]*model.Order, error)
	UpdateOrder(orderID, status string, payerID *string) (bool, error)
	DeleteOrder(orderID string) (bool, error)
}

OrderRepository interface

func NewOrderRepository

func NewOrderRepository() OrderRepository

NewOrderRepository function

type Password

type Password struct {
	Hash string `json:"hash"`
	Salt string `json:"salt"`
}

Password struct

func GeneratePassword

func GeneratePassword(password string) Password

GeneratePassword function

type Payment

type Payment struct {
	ID         string  `bson:"_id,omitempty"`
	PaymentID  string  `bson:"paymentID"`
	PaymentURL string  `bson:"paymentURL"`
	PayerID    *string `bson:"payerID"`
	AuctionID  string  `bson:"auctionID"`
	BidID      string  `bson:"bidID"`
	Status     string  `bson:"status"`
}

Payment struct

type PostRepository

type PostRepository interface {
	GetPosts(sender, author string, page *int) ([]*model.Post, error)
	GetComments(sender, postID string, page *int) ([]*model.PostComment, error)
	CreatePost(author string, content graphql.Upload, description, bidID *string) (string, error)
	EditPost(author, postID, description string) (bool, error)
	DeletePost(author, postID string) (bool, error)
	LikePost(sender, postID string) (bool, error)
	CommentOnPost(sender, postID, message string) (string, error)
	EditComment(sender, postID, commentID, message string) (bool, error)
	DeleteComment(sender, postID, commentID string) (bool, error)
	LikeComment(sender, postID, commentID string) (bool, error)
}

PostRepository interface

func NewPostRepository

func NewPostRepository() PostRepository

NewPostRepository function

type TagSchema

type TagSchema struct {
	ID    string   `json:"_id" bson:"_id"`
	Users []string `json:"users"`
}

TagSchema struct

type TagsRepository

type TagsRepository interface {
	GetTags() ([]string, error)
	GetUserTags(nickname string) ([]string, error)
	GetUsersPerTags(tags []string, page *int) ([]*model.User, error)
	UpdateUserTags(user string, tags []string) (bool, error)
	AddTagToUser(user, tag string) (bool, error)
	RemoveTagFromUser(user, tag string) (bool, error)
}

TagsRepository interface

func NewTagsRepository

func NewTagsRepository() TagsRepository

NewTagsRepository function

type UserRepository

type UserRepository interface {
	CreateUser(user *model.NewUser) (*model.User, error)
	FindOne(nickname string) (*model.User, error)
	FindAll(nickname *string, page *int) ([]*model.User, error)
	Follow(sender, target string) (bool, error)
	Unfollow(sender, target string) (bool, error)
	IsFollowing(sender, target string) bool
	UpdateProfilePicture(sender string, picture graphql.Upload) (string, error)
	UpdateCover(sender string, cover graphql.Upload) (string, error)
	UpdateLocation(sender string, lat, lng float64) (bool, error)
	UpdateBio(sender, bio string) (bool, error)
}

UserRepository Interface

func NewUserRepository

func NewUserRepository() UserRepository

NewUserRepository function

type UserSchema

type UserSchema struct {
	Nickname       string     `json:"nickname" bson:"_id"`
	Name           string     `json:"name"`
	Email          string     `json:"email"`
	Picture        string     `json:"picture"`
	Cover          string     `json:"cover"`
	Bio            string     `json:"bio"`
	Followers      []string   `json:"followers"`
	FollowersCount int        `json:"followerscount"`
	Following      []string   `json:"following"`
	Password       Password   `json:"password"`
	Chats          []userChat `json:"chats"`
	First          bool       `json:"first"`
	Lat            float64    `json:"lat"`
	Lng            float64    `json:"lng"`
}

UserSchema struct

Jump to

Keyboard shortcuts

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