feed

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: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicPost

type BasicPost struct {
	Depth      int           `json:"depth"`
	ID         string        `json:"id"`
	FirstID    string        `json:"first_id"`
	Recipients string        `json:"recipients"`
	ReplyTo    string        `json:"reply_to"`
	Content    template.HTML `json:"content"`
	Date       time.Time     `json:"date"`
	TimeAgo    string        `json:"time_ago"`
	User       User          `json:"user"`
	Likes      int64         `json:"likes"`
	Comments   []BasicPost   `json:"comments"`
}

type Feed

type Feed struct {
	RegionKey   keypair.KeyPair `json:"region_key"`
	Settings    Settings        `json:"settings"`
	PersonalKey keypair.KeyPair `json:"personal_key"`
	// contains filtered or unexported fields
}

Feed stores your basic data

func New

func New(alias, locationToSaveData, regionKeyPublic, regionKeyPrivate string, debug bool) (f *Feed, err error)

New generates a new feed based on the location to find the identity file, the database, and the settings

func (*Feed) AddAddressToServers

func (f *Feed) AddAddressToServers(address string, r Response) (err error)

func (*Feed) AddFriendsKey

func (f *Feed) AddFriendsKey() (err error)

AddFriendsKey will generate a new friends key and post it to the feed

func (*Feed) AmFollowing

func (f *Feed) AmFollowing(publickey string) bool

AmFollowing checks whether the current user is following the public key

func (*Feed) Cleanup

func (f *Feed) Cleanup()

func (*Feed) Debug

func (f *Feed) Debug(b bool)

func (*Feed) DetermineComments

func (f *Feed) DetermineComments(postID string) []BasicPost

func (*Feed) DetermineHashtags

func (f *Feed) DetermineHashtags() (err error)

DetermineHashtags will go through and find all the hashtags

func (*Feed) DownloadEnvelope

func (f *Feed) DownloadEnvelope(address, id string) (err error)

DownloadEnvelope will download the specified envelope

func (*Feed) GetConnected

func (f *Feed) GetConnected() (us []User)

GetConnected returns the users that are currently connected to

func (Feed) GetDatabase

func (self Feed) GetDatabase() database.DatabaseAPI

This is needed for http rest api

func (*Feed) GetEnvelope

func (f *Feed) GetEnvelope(id string) (e letter.Envelope, err error)

GetEnvelope will return an envelope with the given ID

func (*Feed) GetHashTags

func (f *Feed) GetHashTags() (tags []string)

func (*Feed) GetIDs

func (f *Feed) GetIDs(pubkey, signature string) (ids []string, err error)

GetIDs will return an envelope with the given ID

func (*Feed) GetUser

func (f *Feed) GetUser(public ...string) (u User)

GetUser returns the information for a specific user

func (*Feed) GetUserFriends

func (f *Feed) GetUserFriends() (u UserFriends)

GetUserFriends returns detailed friend information

func (*Feed) MakePost

func (f *Feed) MakePost(e letter.Envelope) (post BasicPost)

func (*Feed) MakePostWithComments

func (f *Feed) MakePostWithComments(e letter.Envelope) (post Post)

func (*Feed) MakeSearchIndex

func (f *Feed) MakeSearchIndex() (err error)

MakeSearchIndex will make a search index

func (*Feed) OnlyIncludePostsFromFollowing

func (f *Feed) OnlyIncludePostsFromFollowing(posts []Post) (filteredPosts []Post)

OnlyIncludePostsFromFollowing will filter the posts to include only things from people the user is following

func (*Feed) ProcessEnvelope

func (f *Feed) ProcessEnvelope(e letter.Envelope) (err error)

ProcessEnvelope will determine whether the incoming letter is valid and can be submitted to the database.

func (*Feed) ProcessLetter

func (f *Feed) ProcessLetter(l letter.Letter) (ue letter.Envelope, err error)

ProcessLetter will determine where to put the letter

func (*Feed) PurgeOverflowingStorage

func (f *Feed) PurgeOverflowingStorage() (err error)

PurgeOverflowingStorage will delete old messages

func (*Feed) Save

func (f *Feed) Save() (err error)

func (*Feed) SearchIndexedPosts

func (f *Feed) SearchIndexedPosts(search string) (posts []Post, err error)

func (*Feed) SetRegionKey

func (f *Feed) SetRegionKey(public, private string) (err error)

func (*Feed) ShowFeed

func (f *Feed) ShowFeed(p ShowFeedParameters) (posts []Post, err error)

func (*Feed) SignalUpdate

func (f *Feed) SignalUpdate()

func (*Feed) Sync

func (f *Feed) Sync(address string) (err error)

Sync will try to sync with the respective address

func (*Feed) SyncServers

func (f *Feed) SyncServers()

func (*Feed) TestStuff

func (f *Feed) TestStuff()

func (*Feed) UnsealLetters

func (f *Feed) UnsealLetters() (err error)

UnsealLetters will go through unopened envelopes and open them and then add them to the f.db. Also go through and purge bad letters (invalidated letters)

func (*Feed) UpdateBlockedUsers

func (f *Feed) UpdateBlockedUsers() (err error)

func (*Feed) UpdateEverything

func (f *Feed) UpdateEverything()

func (*Feed) UpdateEverythingAndSync

func (f *Feed) UpdateEverythingAndSync()

func (*Feed) UpdateFriends

func (f *Feed) UpdateFriends() (err error)

UpdateFriends will post keys to friends

func (*Feed) UpdateOnUpload

func (f *Feed) UpdateOnUpload()

func (*Feed) UploadEnvelope

func (f *Feed) UploadEnvelope(address, id string) (err error)

UploadEnvelope will upload the specified envelope

type Post

type Post struct {
	Post     BasicPost   `json:"post"`
	Comments []BasicPost `json:"comments"`
}

type Response

type Response struct {
	PersonalSignature string          `json:"personal_signature"`
	PersonalPublicKey string          `json:"personal_key"`
	IDs               []string        `json:"ids"`
	Envelope          letter.Envelope `json:"envelope"`
	Error             string          `json:"error"`
	Message           string          `json:"message"`
	Status            string          `json:"status"`
}

type Settings

type Settings struct {
	StoragePerPublicPerson int64    `json:"storage_per_person"`  // maximum size in bytes to store of public messages. Once exceeded, old messages are purged
	StoragePerFriend       int64    `json:"storage_per_friend"`  // maximum size in bytes to store of friend messages. Once exceeded, old messages are purged
	FriendsOfFriends       bool     `json:"friends_of_friends"`  // whether you want to share your friends friend keys with new friends, effectively making a new friend friends with all your friends. This also means that when you make a new friend, that friends key is emitted to all your current friends. (default: true)
	BlockPublicPhotos      bool     `json:"block_public_photos"` // if true, block the transfer of any public photos to your computer
	AvailableServers       []string `json:"available_servers"`
}

func GenerateSettings

func GenerateSettings() Settings

GenerateSettings create new instance of Something

type ShowFeedParameters

type ShowFeedParameters struct {
	ID      string // view a single post
	Hashtag string // filter by channel
	User    string // filter by user
	Search  string // filter by search term
	Latest  bool   // get the latest
}

type User

type User struct {
	Name           string            `json:"name"`
	Profile        template.HTML     `json:"profile"`
	ProfileContent template.HTMLAttr `json:"profile_attr"`
	PublicKey      string            `json:"public_key"`
	PublicHash     string            `json:"public_hash"`
	Image          string            `json:"image"`
	Followers      []string          `json:"followers"`
	Following      []string          `json:"following"`
	Friends        []string          `json:"friends"`
	Blocked        []string          `json:"blocked"`
	Server         string            `json:"server"`
}

type UserFriends

type UserFriends struct {
	Friends   []User `json:"user_friends"`
	Followers []User `json:"user_followers"`
	Following []User `json:"user_following"`
}

Jump to

Keyboard shortcuts

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