database

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(verbose bool)

Types

type ApiBasicPost

type ApiBasicPost struct {
	ID          string   `json:"id"`
	Recipients  []string `json:"recipients"`
	ReplyTo     string   `json:"reply_to"`
	Content     string   `json:"content"`
	Timestamp   int64    `json:"timestamp"`
	OwnerId     string   `json:"owner_id"`
	OwnerName   string   `json:"owner_name"`
	Likes       int64    `json:"likes"`
	NumComments int64    `json:"num_comments"`
	Purpose     string   `json:"purpose,omitempty"`
	HashTags    []string `json:"hashtags"`
}

func (*ApiBasicPost) Unmarshal

func (self *ApiBasicPost) Unmarshal(text string) error

type ApiUser

type ApiUser struct {
	Name      string   `json:"name"`
	PublicKey string   `json:"public_key"`
	Profile   string   `json:"profile"`
	Image     string   `json:"image"`
	Followers []string `json:"followers"`
	Following []string `json:"following"`
	Blocked   []string `json:"blocked"`
	Friends   []string `json:"friends"`
}

func (*ApiUser) Unmarshal

func (self *ApiUser) Unmarshal(text string) error

type DatabaseAPI

type DatabaseAPI struct {
	FileName string
}

Publicly acessible database routines

func Setup

func Setup(locationToDatabase string) (api DatabaseAPI)

func (DatabaseAPI) AddEnvelope

func (api DatabaseAPI) AddEnvelope(e letter.Envelope) (err error)

func (DatabaseAPI) AddTags

func (api DatabaseAPI) AddTags(idToTags map[string][]string) (err error)

AddTags will add the tags to the database

func (DatabaseAPI) DeleteOldActions

func (api DatabaseAPI) DeleteOldActions(publicKey string) (err error)

DeleteOldActions will delete all the old actions of a user

func (DatabaseAPI) DeleteProfiles

func (api DatabaseAPI) DeleteProfiles() (err error)

DeleteProfiles will delete everything for all users that have submitted an action-erase

func (DatabaseAPI) DeleteUser

func (api DatabaseAPI) DeleteUser(publicKey string) (err error)

DeleteUser will delete everything for all users that have submitted an action-erase

func (DatabaseAPI) DeleteUsersEdits

func (api DatabaseAPI) DeleteUsersEdits(publicKey string) (err error)

DeleteUsersEdits will delete the users edits made to posts

func (DatabaseAPI) DeleteUsersOldestLargestPost added in v0.1.0

func (api DatabaseAPI) DeleteUsersOldestLargestPost(publicKey string) (err error)

DeleteUsersOldestPost will delete the users oldest post

func (DatabaseAPI) DeleteUsersOldestPost

func (api DatabaseAPI) DeleteUsersOldestPost(publicKey string) (err error)

DeleteUsersOldestPost will delete the users oldest post

func (DatabaseAPI) DiskSpaceForUser

func (api DatabaseAPI) DiskSpaceForUser(user string) (diskSpace int64, err error)

DiskSpaceForUser returns the bytes used by a user for recipients + sealed_content

func (DatabaseAPI) Friends

func (api DatabaseAPI) Friends(publicKey string) (followers, following, friends []string)

Friends will return the followers, following and friends for a given user

func (DatabaseAPI) Get

func (api DatabaseAPI) Get(bucket, key string, value interface{}) (err error)

func (DatabaseAPI) GetAllEnvelopes

func (api DatabaseAPI) GetAllEnvelopes(opened ...bool) (e []letter.Envelope, err error)

GetAllEnvelopes returns all envelopes determined by whether they are opened

func (DatabaseAPI) GetAllVersions

func (api DatabaseAPI) GetAllVersions(id string) (ids []string, err error)

GetAllVersions returns the bytes used by a user for recipients + sealed_content

func (DatabaseAPI) GetBasicPostLatest

func (api DatabaseAPI) GetBasicPostLatest(publickey string) (e letter.Envelope, err error)

GetBasicPostLatest returns the latest post for a person

func (DatabaseAPI) GetBasicPosts

func (api DatabaseAPI) GetBasicPosts() (e []letter.Envelope, err error)

func (DatabaseAPI) GetBasicPostsForUser

func (api DatabaseAPI) GetBasicPostsForUser(publickey string) (e []letter.Envelope, err error)

func (DatabaseAPI) GetEnvelopeFromID

func (api DatabaseAPI) GetEnvelopeFromID(id string) (e letter.Envelope, err error)

GetEnvelopeFromID returns a single envelope from its ID and returns an error if it does not exist.

func (DatabaseAPI) GetEnvelopesFromTag

func (api DatabaseAPI) GetEnvelopesFromTag(tag string) (es []letter.Envelope, err error)

GetEnvelopesFromTag uses the hashtag table to get the latest post for a hashtag.

func (DatabaseAPI) GetEnvelopesFromTag1

func (api DatabaseAPI) GetEnvelopesFromTag1(tag string) (es []letter.Envelope, err error)

func (DatabaseAPI) GetFriendsName

func (api DatabaseAPI) GetFriendsName(publicKey string) (name string)

GetFriendsName will search friend's keys and determine the name of the friends key, e.g. Zack's Friends (where Zack is assigned name of public key)

func (DatabaseAPI) GetIDs

func (api DatabaseAPI) GetIDs() (ids map[string]struct{}, err error)

GetIDs will delete the letter containing that ID

func (DatabaseAPI) GetKeys

func (api DatabaseAPI) GetKeys() (s []keypair.KeyPair, err error)

GetKeys will return all the keys

func (DatabaseAPI) GetKeysFromSender

func (api DatabaseAPI) GetKeysFromSender(sender string) (s []keypair.KeyPair, err error)

GetKeysFromSender will return all the keys from a certain sender

func (DatabaseAPI) GetLatestEnvelopeFromID

func (api DatabaseAPI) GetLatestEnvelopeFromID(id string) (e letter.Envelope, err error)

GetLatestEnvelopeFromID returns a single envelope from its ID, trying to find the latest version of it

func (DatabaseAPI) GetLatestKeyForFriends

func (api DatabaseAPI) GetLatestKeyForFriends(publicKey string) (key keypair.KeyPair, err error)

GetLatestKeyForFriends will return the latest key for encrypting messages to friends

func (DatabaseAPI) GetName

func (api DatabaseAPI) GetName(publicKey string) (name string)

GetName will return the assigned name for the public key of a sender

func (DatabaseAPI) GetPostCommentsForApi

func (self DatabaseAPI) GetPostCommentsForApi(post_id string) ([]ApiBasicPost, error)

func (DatabaseAPI) GetPostForApi

func (self DatabaseAPI) GetPostForApi(post_id string) ([]ApiBasicPost, error)

func (DatabaseAPI) GetPostVersionsForApi

func (self DatabaseAPI) GetPostVersionsForApi(post_id string) ([]ApiBasicPost, error)

func (DatabaseAPI) GetPostsForApi

func (self DatabaseAPI) GetPostsForApi() ([]ApiBasicPost, error)

json1 needs to be loaded...

func (DatabaseAPI) GetProfile

func (api DatabaseAPI) GetProfile(publicKey string) (name string)

GetProfile will return the assigned profile for the public key of a sender

func (DatabaseAPI) GetProfileImage

func (api DatabaseAPI) GetProfileImage(publicKey string) (imageID string)

GetProfile will return the assigned profile for the public key of a sender

func (DatabaseAPI) GetReplies

func (api DatabaseAPI) GetReplies(id string) (e []letter.Envelope, err error)

GetReplies returns all envelopes that are replies to a specific envelope

func (DatabaseAPI) GetUser

func (api DatabaseAPI) GetUser(publicKey string) (name, profile, image string)

GetUser returns information for a user

func (DatabaseAPI) GetUserForApi

func (self DatabaseAPI) GetUserForApi(user_id string) (ApiUser, error)

func (DatabaseAPI) IsReplaced

func (api DatabaseAPI) IsReplaced(id string) (yes bool)

IsReplaced returns boolean of whether post with ID has been replaced

func (DatabaseAPI) ListBlockedUsers

func (api DatabaseAPI) ListBlockedUsers(publickey string) (users []string, err error)

ListBlockedUsers returns the bytes used by a user for recipients + sealed_content

func (DatabaseAPI) ListUsers

func (api DatabaseAPI) ListUsers() (users []string, err error)

ListUsers returns the bytes used by a user for recipients + sealed_content

func (DatabaseAPI) NumberOfLikes

func (api DatabaseAPI) NumberOfLikes(postID string) (likes int64)

NumberOfLikes returns the number of likes for a post

func (DatabaseAPI) RemoveLetters

func (api DatabaseAPI) RemoveLetters(ids []string) (err error)

RemoveLetters will delete the letter containing that ID

func (DatabaseAPI) RemoveLettersForUser

func (api DatabaseAPI) RemoveLettersForUser(user string) (err error)

RemoveLettersForUser will delete the envelopes for a specific user

func (DatabaseAPI) Set

func (api DatabaseAPI) Set(bucket, key string, value interface{}) (err error)

func (DatabaseAPI) UpdateEnvelope

func (api DatabaseAPI) UpdateEnvelope(e letter.Envelope) (err error)

Jump to

Keyboard shortcuts

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