Documentation
¶
Overview ¶
Package sone implements a Go port of the Sone social networking plugin for Hyphanet.
Index ¶
- Constants
- func EscapeXML(s string) string
- func FindMentionedSones(parts []Part) []string
- func HasMentionOf(parts []Part, soneID string) bool
- func RenderPartsToHTML(parts []Part) string
- func RenderPartsToPlainText(parts []Part) string
- type Album
- type AlbumXML
- type AlbumsXML
- type CachedImage
- type Client
- type ClientXML
- type Config
- type Core
- func (c *Core) CreatePost(soneID string, text string, recipientID *string) (*Post, error)
- func (c *Core) CreateReply(soneID string, postID string, text string) (*PostReply, error)
- func (c *Core) Database() Database
- func (c *Core) DeletePost(soneID string, postID string) error
- func (c *Core) DeleteReply(soneID string, replyID string) error
- func (c *Core) DismissNotification(id string)
- func (c *Core) EventBus() *EventBus
- func (c *Core) FCPClient() *fcp.Client
- func (c *Core) FollowSone(localSoneID string, remoteSoneID string) error
- func (c *Core) GetAllSones() []*Sone
- func (c *Core) GetLocalSone(id string) *Sone
- func (c *Core) GetLocalSones() []*Sone
- func (c *Core) GetNotifications() []*Notification
- func (c *Core) GetPostFeed(soneID string) []*Post
- func (c *Core) GetSone(id string) *Sone
- func (c *Core) LikePost(soneID string, postID string) error
- func (c *Core) ProcessFetchedSone(soneID string, data []byte) error
- func (c *Core) Start() error
- func (c *Core) Stop() error
- func (c *Core) UnfollowSone(localSoneID string, remoteSoneID string) error
- func (c *Core) UnlikePost(soneID string, postID string) error
- type Database
- type DatabaseState
- type Event
- type EventBus
- func (eb *EventBus) Publish(event Event)
- func (eb *EventBus) PublishMentionDetected(post *Post, mentionedSoneID string)
- func (eb *EventBus) PublishNewPostFound(post *Post)
- func (eb *EventBus) PublishNewReplyFound(reply *PostReply)
- func (eb *EventBus) PublishPostRemoved(post *Post)
- func (eb *EventBus) PublishReplyRemoved(reply *PostReply)
- func (eb *EventBus) PublishSoneDiscovered(sone *Sone)
- func (eb *EventBus) PublishSoneInsertAborted(sone *Sone, reason string)
- func (eb *EventBus) PublishSoneInserted(sone *Sone, edition int64)
- func (eb *EventBus) PublishSoneInserting(sone *Sone)
- func (eb *EventBus) PublishSoneUpdated(sone *Sone)
- func (eb *EventBus) Start()
- func (eb *EventBus) Stop()
- func (eb *EventBus) Subscribe(eventType EventType, handler EventHandler)
- func (eb *EventBus) SubscribeAll(handler EventHandler)
- type EventHandler
- type EventType
- type Field
- type FieldXML
- type FieldsXML
- type FreemailPart
- type FreenetLinkPart
- type HTTPLinkPart
- type Image
- type ImageManager
- func (m *ImageManager) ClearCache()
- func (m *ImageManager) CreateAlbum(soneID string, title string, parentID string) (*Album, error)
- func (m *ImageManager) DeleteAlbum(soneID string, albumID string) error
- func (m *ImageManager) DeleteImage(soneID string, imageID string) error
- func (m *ImageManager) GetAlbums(soneID string) []*Album
- func (m *ImageManager) GetImage(uri string) (*CachedImage, error)
- func (m *ImageManager) GetUpload(uploadID string) *ImageUpload
- func (m *ImageManager) MoveImage(soneID string, imageID string, targetAlbumID string) error
- func (m *ImageManager) UploadImage(soneID string, albumID string, filename string, data []byte, ...) (*ImageUpload, error)
- type ImageUpload
- type ImageUploadCallback
- type ImageXML
- type ImagesXML
- type MemoryDatabase
- func (db *MemoryDatabase) AddBookmark(postID string) error
- func (db *MemoryDatabase) AddFriend(soneID, friendID string) error
- func (db *MemoryDatabase) GetAlbum(id string) *Album
- func (db *MemoryDatabase) GetAlbumsBySone(soneID string) []*Album
- func (db *MemoryDatabase) GetAllPosts() []*Post
- func (db *MemoryDatabase) GetAllSones() []*Sone
- func (db *MemoryDatabase) GetBookmarkedPosts() []string
- func (db *MemoryDatabase) GetFriends(soneID string) []string
- func (db *MemoryDatabase) GetImage(id string) *Image
- func (db *MemoryDatabase) GetImagesByAlbum(albumID string) []*Image
- func (db *MemoryDatabase) GetLocalSones() []*Sone
- func (db *MemoryDatabase) GetPost(id string) *Post
- func (db *MemoryDatabase) GetPostsBySone(soneID string) []*Post
- func (db *MemoryDatabase) GetRepliesByPost(postID string) []*PostReply
- func (db *MemoryDatabase) GetRepliesBySone(soneID string) []*PostReply
- func (db *MemoryDatabase) GetReply(id string) *PostReply
- func (db *MemoryDatabase) GetSone(id string) *Sone
- func (db *MemoryDatabase) IsBookmarked(postID string) bool
- func (db *MemoryDatabase) IsFriend(soneID, friendID string) bool
- func (db *MemoryDatabase) IsPostKnown(id string) bool
- func (db *MemoryDatabase) IsReplyKnown(id string) bool
- func (db *MemoryDatabase) Load() error
- func (db *MemoryDatabase) RemoveAlbum(id string) error
- func (db *MemoryDatabase) RemoveBookmark(postID string) error
- func (db *MemoryDatabase) RemoveFriend(soneID, friendID string) error
- func (db *MemoryDatabase) RemoveImage(id string) error
- func (db *MemoryDatabase) RemovePost(id string) error
- func (db *MemoryDatabase) RemoveReply(id string) error
- func (db *MemoryDatabase) RemoveSone(id string) error
- func (db *MemoryDatabase) Save() error
- func (db *MemoryDatabase) SetPostKnown(id string, known bool) error
- func (db *MemoryDatabase) SetReplyKnown(id string, known bool) error
- func (db *MemoryDatabase) StoreAlbum(album *Album) error
- func (db *MemoryDatabase) StoreImage(image *Image) error
- func (db *MemoryDatabase) StorePost(post *Post) error
- func (db *MemoryDatabase) StoreReply(reply *PostReply) error
- func (db *MemoryDatabase) StoreSone(sone *Sone) error
- type MentionDetector
- type Notification
- type NotificationManager
- type Part
- type PartType
- type PlainTextPart
- type Post
- type PostLikesXML
- type PostLinkPart
- type PostReply
- type PostXML
- type PostsXML
- type Profile
- type ProfileXML
- type RepliesXML
- type ReplyLikesXML
- type ReplyXML
- type Sone
- func (s *Sone) AddFriend(soneID string)
- func (s *Sone) GetFingerprint() string
- func (s *Sone) HasFriend(soneID string) bool
- func (s *Sone) IsPostLiked(postID string) bool
- func (s *Sone) IsReplyLiked(replyID string) bool
- func (s *Sone) LikePost(postID string)
- func (s *Sone) LikeReply(replyID string)
- func (s *Sone) RemoveFriend(soneID string)
- func (s *Sone) ToXML(clientName, clientVersion string) ([]byte, error)
- func (s *Sone) UnlikePost(postID string)
- func (s *Sone) UnlikeReply(replyID string)
- type SoneDownloader
- type SoneInserter
- type SoneLinkPart
- type SoneStatus
- type SoneXML
- type TextParser
- type USKMonitor
- type UploadStatus
Constants ¶
const ClientName = "GoSone"
ClientName is the client name reported in Sone XML
const EventSoneUpdating = EventType(100)
EventSoneUpdating is published when a Sone update is detected
const ProtocolVersion = 0
ProtocolVersion is the Sone XML protocol version
const Version = "0.1.0"
Version is the GoSone client version
Variables ¶
This section is empty.
Functions ¶
func FindMentionedSones ¶
FindMentionedSones finds all Sone IDs mentioned in parts
func HasMentionOf ¶
HasMentionOf checks if parts contain a mention of the given Sone ID
func RenderPartsToHTML ¶
RenderPartsToHTML converts parts to HTML
func RenderPartsToPlainText ¶
RenderPartsToPlainText converts parts to plain text
Types ¶
type Album ¶
type Album struct {
ID string
SoneID string // Owner Sone ID
ParentID *string // Parent album ID (nil for root)
Title string
Description string
AlbumImage string // ID of the album cover image
Albums []*Album // Nested albums
Images []*Image
IsRoot bool
}
Album is a container for images
func NewRootAlbum ¶
NewRootAlbum creates a new root album for a Sone
func (*Album) GetFingerprint ¶
GetFingerprint returns a hash of the album for change detection
func (*Album) RemoveAlbum ¶
RemoveAlbum removes a nested album
func (*Album) RemoveImage ¶
RemoveImage removes an image from the album
type AlbumXML ¶
type AlbumXML struct {
ID string `xml:"id"`
Parent string `xml:"parent,omitempty"`
Title string `xml:"title"`
Description string `xml:"description"`
AlbumImage string `xml:"album-image"`
Images *ImagesXML `xml:"images,omitempty"`
}
AlbumXML represents a single album
type AlbumsXML ¶
type AlbumsXML struct {
Albums []AlbumXML `xml:"album"`
}
AlbumsXML represents the albums section
type CachedImage ¶
type CachedImage struct {
URI string
Data []byte
MimeType string
Width int
Height int
FetchTime time.Time
}
CachedImage represents a cached image
type Config ¶
type Config struct {
DataDir string // Directory for persistent data
FCPHost string // Freenet FCP host
FCPPort int // Freenet FCP port
InsertionDelay time.Duration // Delay between insertions
RefreshInterval time.Duration // Interval for checking Sone updates
SoneContext string // WoT context for Sone (default: "Sone")
}
Config holds configuration for the Sone core
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core is the main Sone application component
func (*Core) CreatePost ¶
CreatePost creates a new post for a local Sone
func (*Core) CreateReply ¶
CreateReply creates a reply to a post
func (*Core) DeletePost ¶
DeletePost removes a post
func (*Core) DeleteReply ¶
DeleteReply removes a reply
func (*Core) DismissNotification ¶
DismissNotification dismisses a notification
func (*Core) FollowSone ¶
FollowSone adds a Sone to the follow list
func (*Core) GetLocalSone ¶
GetLocalSone returns a local Sone by ID
func (*Core) GetLocalSones ¶
GetLocalSones returns all local Sones
func (*Core) GetNotifications ¶
func (c *Core) GetNotifications() []*Notification
GetNotifications returns current notifications
func (*Core) GetPostFeed ¶
GetPostFeed returns posts for a Sone's feed
func (*Core) ProcessFetchedSone ¶
ProcessFetchedSone processes a fetched Sone XML
func (*Core) UnfollowSone ¶
UnfollowSone removes a Sone from the follow list
type Database ¶
type Database interface {
// Sone operations
GetSone(id string) *Sone
GetAllSones() []*Sone
GetLocalSones() []*Sone
StoreSone(sone *Sone) error
RemoveSone(id string) error
// Post operations
GetPost(id string) *Post
GetPostsBySone(soneID string) []*Post
GetAllPosts() []*Post
StorePost(post *Post) error
RemovePost(id string) error
IsPostKnown(id string) bool
SetPostKnown(id string, known bool) error
// Reply operations
GetReply(id string) *PostReply
GetRepliesByPost(postID string) []*PostReply
GetRepliesBySone(soneID string) []*PostReply
StoreReply(reply *PostReply) error
RemoveReply(id string) error
IsReplyKnown(id string) bool
SetReplyKnown(id string, known bool) error
// Album operations
GetAlbum(id string) *Album
GetAlbumsBySone(soneID string) []*Album
StoreAlbum(album *Album) error
RemoveAlbum(id string) error
// Image operations
GetImage(id string) *Image
GetImagesByAlbum(albumID string) []*Image
StoreImage(image *Image) error
RemoveImage(id string) error
// Friends
GetFriends(soneID string) []string
AddFriend(soneID, friendID string) error
RemoveFriend(soneID, friendID string) error
IsFriend(soneID, friendID string) bool
// Bookmarks
GetBookmarkedPosts() []string
AddBookmark(postID string) error
RemoveBookmark(postID string) error
IsBookmarked(postID string) bool
// Persistence
Save() error
Load() error
}
Database provides storage for Sone data
type DatabaseState ¶
type DatabaseState struct {
KnownPosts []string `json:"known_posts"`
KnownReplies []string `json:"known_replies"`
Bookmarks []string `json:"bookmarks"`
Friends map[string][]string `json:"friends"`
}
DatabaseState represents the serializable state of the database
type Event ¶
type Event struct {
Type EventType
Sone *Sone
Post *Post
Reply *PostReply
Image *Image
Message string
Data interface{}
}
Event represents a Sone event
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus provides pub/sub functionality for Sone events
func (*EventBus) PublishMentionDetected ¶
PublishMentionDetected publishes a mention detected event
func (*EventBus) PublishNewPostFound ¶
PublishNewPostFound publishes a new post found event
func (*EventBus) PublishNewReplyFound ¶
PublishNewReplyFound publishes a new reply found event
func (*EventBus) PublishPostRemoved ¶
PublishPostRemoved publishes a post removed event
func (*EventBus) PublishReplyRemoved ¶
PublishReplyRemoved publishes a reply removed event
func (*EventBus) PublishSoneDiscovered ¶
PublishSoneDiscovered publishes a new Sone discovered event
func (*EventBus) PublishSoneInsertAborted ¶
PublishSoneInsertAborted publishes a Sone insert aborted event
func (*EventBus) PublishSoneInserted ¶
PublishSoneInserted publishes a Sone inserted event
func (*EventBus) PublishSoneInserting ¶
PublishSoneInserting publishes a Sone inserting event
func (*EventBus) PublishSoneUpdated ¶
PublishSoneUpdated publishes a Sone updated event
func (*EventBus) Subscribe ¶
func (eb *EventBus) Subscribe(eventType EventType, handler EventHandler)
Subscribe registers a handler for a specific event type
func (*EventBus) SubscribeAll ¶
func (eb *EventBus) SubscribeAll(handler EventHandler)
SubscribeAll registers a handler for all event types
type EventType ¶
type EventType int
EventType represents the type of Sone event
const ( // Sone events EventSoneDiscovered EventType = iota EventSoneUpdated EventSoneRemoved EventLocalSoneAdded EventLocalSoneRemoved EventSoneInserting EventSoneInserted EventSoneInsertAborted // Post events EventNewPostFound EventPostRemoved EventPostMarkedKnown // Reply events EventNewReplyFound EventReplyRemoved EventReplyMarkedKnown // Image events EventImageInsertStarted EventImageInsertFinished EventImageInsertFailed // Notification events EventMentionDetected )
type FieldsXML ¶
type FieldsXML struct {
Fields []FieldXML `xml:"field"`
}
FieldsXML represents profile fields
type FreemailPart ¶
type FreemailPart struct {
LocalPart string // Part before @
FreemailID string // Base32 identity
IdentityID string // Decoded identity ID
}
FreemailPart represents a Freemail address
func (*FreemailPart) Text ¶
func (p *FreemailPart) Text() string
func (*FreemailPart) ToHTML ¶
func (p *FreemailPart) ToHTML() string
func (*FreemailPart) ToPlainText ¶
func (p *FreemailPart) ToPlainText() string
func (*FreemailPart) Type ¶
func (p *FreemailPart) Type() PartType
type FreenetLinkPart ¶
type FreenetLinkPart struct {
Link string // Full URI
DisplayText string // Shortened display text
Trusted bool // True if from trusted Sone
}
FreenetLinkPart represents a Freenet URI (KSK@, SSK@, USK@, CHK@)
func (*FreenetLinkPart) Text ¶
func (p *FreenetLinkPart) Text() string
func (*FreenetLinkPart) ToHTML ¶
func (p *FreenetLinkPart) ToHTML() string
func (*FreenetLinkPart) ToPlainText ¶
func (p *FreenetLinkPart) ToPlainText() string
func (*FreenetLinkPart) Type ¶
func (p *FreenetLinkPart) Type() PartType
type HTTPLinkPart ¶
HTTPLinkPart represents an HTTP/HTTPS URL
func (*HTTPLinkPart) Text ¶
func (p *HTTPLinkPart) Text() string
func (*HTTPLinkPart) ToHTML ¶
func (p *HTTPLinkPart) ToHTML() string
func (*HTTPLinkPart) ToPlainText ¶
func (p *HTTPLinkPart) ToPlainText() string
func (*HTTPLinkPart) Type ¶
func (p *HTTPLinkPart) Type() PartType
type Image ¶
type Image struct {
ID string
SoneID string // Owner Sone ID
AlbumID string // Parent album ID
Key string // Freenet URI
CreationTime int64 // Unix milliseconds
Title string
Description string
Width int
Height int
MimeType string
}
Image represents an image uploaded to Hyphanet
func (*Image) GetFingerprint ¶
GetFingerprint returns a hash of the image for change detection
func (*Image) IsInserted ¶
IsInserted returns true if the image has been inserted to Hyphanet
type ImageManager ¶
type ImageManager struct {
// contains filtered or unexported fields
}
ImageManager handles image uploads and retrieval
func NewImageManager ¶
func NewImageManager(core *Core) *ImageManager
NewImageManager creates a new image manager
func (*ImageManager) ClearCache ¶
func (m *ImageManager) ClearCache()
ClearCache clears the image cache
func (*ImageManager) CreateAlbum ¶
CreateAlbum creates a new album for a Sone
func (*ImageManager) DeleteAlbum ¶
func (m *ImageManager) DeleteAlbum(soneID string, albumID string) error
DeleteAlbum deletes an album and all its contents
func (*ImageManager) DeleteImage ¶
func (m *ImageManager) DeleteImage(soneID string, imageID string) error
DeleteImage deletes an image from an album
func (*ImageManager) GetAlbums ¶
func (m *ImageManager) GetAlbums(soneID string) []*Album
GetAlbums returns all albums for a Sone
func (*ImageManager) GetImage ¶
func (m *ImageManager) GetImage(uri string) (*CachedImage, error)
GetImage retrieves an image from Hyphanet (with caching)
func (*ImageManager) GetUpload ¶
func (m *ImageManager) GetUpload(uploadID string) *ImageUpload
GetUpload returns an upload by ID
func (*ImageManager) MoveImage ¶
func (m *ImageManager) MoveImage(soneID string, imageID string, targetAlbumID string) error
MoveImage moves an image to a different album
func (*ImageManager) UploadImage ¶
func (m *ImageManager) UploadImage(soneID string, albumID string, filename string, data []byte, callback ImageUploadCallback) (*ImageUpload, error)
UploadImage uploads an image to Hyphanet
type ImageUpload ¶
type ImageUpload struct {
ID string
AlbumID string
Filename string
MimeType string
Width int
Height int
Data []byte
Status UploadStatus
Progress float64
Error string
ResultURI string
StartTime time.Time
Callbacks []ImageUploadCallback
// contains filtered or unexported fields
}
ImageUpload represents an ongoing image upload
type ImageUploadCallback ¶
type ImageUploadCallback func(upload *ImageUpload)
ImageUploadCallback is called when upload status changes
type ImageXML ¶
type ImageXML struct {
ID string `xml:"id"`
CreationTime int64 `xml:"creation-time"`
Key string `xml:"key"`
Title string `xml:"title"`
Description string `xml:"description"`
Width int `xml:"width"`
Height int `xml:"height"`
}
ImageXML represents a single image
type ImagesXML ¶
type ImagesXML struct {
Images []ImageXML `xml:"image"`
}
ImagesXML represents images in an album
type MemoryDatabase ¶
type MemoryDatabase struct {
// contains filtered or unexported fields
}
MemoryDatabase is an in-memory implementation of Database
func NewMemoryDatabase ¶
func NewMemoryDatabase(dataDir string) *MemoryDatabase
NewMemoryDatabase creates a new in-memory database
func (*MemoryDatabase) AddBookmark ¶
func (db *MemoryDatabase) AddBookmark(postID string) error
func (*MemoryDatabase) AddFriend ¶
func (db *MemoryDatabase) AddFriend(soneID, friendID string) error
func (*MemoryDatabase) GetAlbum ¶
func (db *MemoryDatabase) GetAlbum(id string) *Album
func (*MemoryDatabase) GetAlbumsBySone ¶
func (db *MemoryDatabase) GetAlbumsBySone(soneID string) []*Album
func (*MemoryDatabase) GetAllPosts ¶
func (db *MemoryDatabase) GetAllPosts() []*Post
func (*MemoryDatabase) GetAllSones ¶
func (db *MemoryDatabase) GetAllSones() []*Sone
func (*MemoryDatabase) GetBookmarkedPosts ¶
func (db *MemoryDatabase) GetBookmarkedPosts() []string
func (*MemoryDatabase) GetFriends ¶
func (db *MemoryDatabase) GetFriends(soneID string) []string
func (*MemoryDatabase) GetImage ¶
func (db *MemoryDatabase) GetImage(id string) *Image
func (*MemoryDatabase) GetImagesByAlbum ¶
func (db *MemoryDatabase) GetImagesByAlbum(albumID string) []*Image
func (*MemoryDatabase) GetLocalSones ¶
func (db *MemoryDatabase) GetLocalSones() []*Sone
func (*MemoryDatabase) GetPost ¶
func (db *MemoryDatabase) GetPost(id string) *Post
func (*MemoryDatabase) GetPostsBySone ¶
func (db *MemoryDatabase) GetPostsBySone(soneID string) []*Post
func (*MemoryDatabase) GetRepliesByPost ¶
func (db *MemoryDatabase) GetRepliesByPost(postID string) []*PostReply
func (*MemoryDatabase) GetRepliesBySone ¶
func (db *MemoryDatabase) GetRepliesBySone(soneID string) []*PostReply
func (*MemoryDatabase) GetReply ¶
func (db *MemoryDatabase) GetReply(id string) *PostReply
func (*MemoryDatabase) GetSone ¶
func (db *MemoryDatabase) GetSone(id string) *Sone
func (*MemoryDatabase) IsBookmarked ¶
func (db *MemoryDatabase) IsBookmarked(postID string) bool
func (*MemoryDatabase) IsFriend ¶
func (db *MemoryDatabase) IsFriend(soneID, friendID string) bool
func (*MemoryDatabase) IsPostKnown ¶
func (db *MemoryDatabase) IsPostKnown(id string) bool
func (*MemoryDatabase) IsReplyKnown ¶
func (db *MemoryDatabase) IsReplyKnown(id string) bool
func (*MemoryDatabase) Load ¶
func (db *MemoryDatabase) Load() error
func (*MemoryDatabase) RemoveAlbum ¶
func (db *MemoryDatabase) RemoveAlbum(id string) error
func (*MemoryDatabase) RemoveBookmark ¶
func (db *MemoryDatabase) RemoveBookmark(postID string) error
func (*MemoryDatabase) RemoveFriend ¶
func (db *MemoryDatabase) RemoveFriend(soneID, friendID string) error
func (*MemoryDatabase) RemoveImage ¶
func (db *MemoryDatabase) RemoveImage(id string) error
func (*MemoryDatabase) RemovePost ¶
func (db *MemoryDatabase) RemovePost(id string) error
func (*MemoryDatabase) RemoveReply ¶
func (db *MemoryDatabase) RemoveReply(id string) error
func (*MemoryDatabase) RemoveSone ¶
func (db *MemoryDatabase) RemoveSone(id string) error
func (*MemoryDatabase) Save ¶
func (db *MemoryDatabase) Save() error
func (*MemoryDatabase) SetPostKnown ¶
func (db *MemoryDatabase) SetPostKnown(id string, known bool) error
func (*MemoryDatabase) SetReplyKnown ¶
func (db *MemoryDatabase) SetReplyKnown(id string, known bool) error
func (*MemoryDatabase) StoreAlbum ¶
func (db *MemoryDatabase) StoreAlbum(album *Album) error
func (*MemoryDatabase) StoreImage ¶
func (db *MemoryDatabase) StoreImage(image *Image) error
func (*MemoryDatabase) StorePost ¶
func (db *MemoryDatabase) StorePost(post *Post) error
func (*MemoryDatabase) StoreReply ¶
func (db *MemoryDatabase) StoreReply(reply *PostReply) error
func (*MemoryDatabase) StoreSone ¶
func (db *MemoryDatabase) StoreSone(sone *Sone) error
type MentionDetector ¶
type MentionDetector struct {
// contains filtered or unexported fields
}
MentionDetector detects mentions of local Sones in posts/replies
func NewMentionDetector ¶
func NewMentionDetector(textParser *TextParser, eventBus *EventBus) *MentionDetector
NewMentionDetector creates a new mention detector
func (*MentionDetector) CheckPost ¶
func (md *MentionDetector) CheckPost(post *Post) bool
CheckPost checks a post for mentions of local Sones
func (*MentionDetector) CheckReply ¶
func (md *MentionDetector) CheckReply(reply *PostReply) bool
CheckReply checks a reply for mentions of local Sones
func (*MentionDetector) SetLocalSones ¶
func (md *MentionDetector) SetLocalSones(soneIDs []string)
SetLocalSones updates the set of local Sone IDs
type Notification ¶
type Notification struct {
ID string
Type string
Text string
CreatedTime int64
Dismissable bool
Elements []interface{}
}
Notification represents a user notification
type NotificationManager ¶
type NotificationManager struct {
// contains filtered or unexported fields
}
NotificationManager manages user notifications
func NewNotificationManager ¶
func NewNotificationManager(eventBus *EventBus) *NotificationManager
NewNotificationManager creates a new notification manager
func (*NotificationManager) ClearNotification ¶
func (nm *NotificationManager) ClearNotification(id string)
ClearNotification clears elements from a notification
func (*NotificationManager) DismissNotification ¶
func (nm *NotificationManager) DismissNotification(id string)
DismissNotification removes a notification
func (*NotificationManager) GetNotifications ¶
func (nm *NotificationManager) GetNotifications() []*Notification
GetNotifications returns all current notifications
type PlainTextPart ¶
type PlainTextPart struct {
Content string
}
PlainTextPart represents plain text
func (*PlainTextPart) Text ¶
func (p *PlainTextPart) Text() string
func (*PlainTextPart) ToHTML ¶
func (p *PlainTextPart) ToHTML() string
func (*PlainTextPart) ToPlainText ¶
func (p *PlainTextPart) ToPlainText() string
func (*PlainTextPart) Type ¶
func (p *PlainTextPart) Type() PartType
type Post ¶
type Post struct {
ID string
SoneID string // Author's Sone ID
RecipientID *string // Optional recipient Sone ID
Time int64 // Unix milliseconds
Text string
IsKnown bool // True if user has seen this post
IsLoaded bool // True if post data has been loaded
}
Post represents a status update posted by a Sone
func (*Post) GetFingerprint ¶
GetFingerprint returns a hash of the post for change detection
type PostLikesXML ¶
type PostLikesXML struct {
PostLikes []string `xml:"post-like"`
}
PostLikesXML represents liked posts
type PostLinkPart ¶
PostLinkPart represents a post:// link
func (*PostLinkPart) Text ¶
func (p *PostLinkPart) Text() string
func (*PostLinkPart) ToHTML ¶
func (p *PostLinkPart) ToHTML() string
func (*PostLinkPart) ToPlainText ¶
func (p *PostLinkPart) ToPlainText() string
func (*PostLinkPart) Type ¶
func (p *PostLinkPart) Type() PartType
type PostReply ¶
type PostReply struct {
ID string
SoneID string // Author's Sone ID
PostID string // Post being replied to
Time int64 // Unix milliseconds
Text string
IsKnown bool // True if user has seen this reply
IsLoaded bool // True if reply data has been loaded
}
PostReply represents a reply to a post
func NewPostReply ¶
NewPostReply creates a new reply
func (*PostReply) GetFingerprint ¶
GetFingerprint returns a hash of the reply for change detection
type PostXML ¶
type PostXML struct {
ID string `xml:"id"`
Recipient string `xml:"recipient"`
Time int64 `xml:"time"`
Text string `xml:"text"`
}
PostXML represents a single post
type PostsXML ¶
type PostsXML struct {
Posts []PostXML `xml:"post"`
}
PostsXML represents the posts section
type Profile ¶
type Profile struct {
FirstName string
MiddleName string
LastName string
BirthDay *int
BirthMonth *int
BirthYear *int
Avatar string // Image ID
Fields []*Field // Custom profile fields
}
Profile contains personal information about a Sone
func (*Profile) GetFieldByName ¶
GetFieldByName returns a field by name
func (*Profile) GetFingerprint ¶
GetFingerprint returns a hash of the profile for change detection
func (*Profile) RemoveField ¶
RemoveField removes a field from the profile
type ProfileXML ¶
type ProfileXML struct {
FirstName string `xml:"first-name"`
MiddleName string `xml:"middle-name"`
LastName string `xml:"last-name"`
BirthDay string `xml:"birth-day"`
BirthMonth string `xml:"birth-month"`
BirthYear string `xml:"birth-year"`
Avatar string `xml:"avatar"`
Fields *FieldsXML `xml:"fields"`
}
ProfileXML represents the profile section in XML
type RepliesXML ¶
type RepliesXML struct {
Replies []ReplyXML `xml:"reply"`
}
RepliesXML represents the replies section
type ReplyLikesXML ¶
type ReplyLikesXML struct {
ReplyLikes []string `xml:"reply-like"`
}
ReplyLikesXML represents liked replies
type ReplyXML ¶
type ReplyXML struct {
ID string `xml:"id"`
PostID string `xml:"post-id"`
Time int64 `xml:"time"`
Text string `xml:"text"`
}
ReplyXML represents a single reply
type Sone ¶
type Sone struct {
// Identity from Web of Trust
ID string // Same as WoT identity ID (43-char base64)
Identity *wot.Identity // WoT identity reference
// Basic info
Name string // Display name (from WoT nickname)
RequestURI string // Freenet URI for fetching this Sone
InsertURI string // Freenet URI for inserting (only for local Sones)
LatestEdition int64 // Latest known edition number
Time int64 // Time of last update (Unix milliseconds)
Status SoneStatus // Current status
// Profile
Profile *Profile
// Client info
Client *Client
// Content
Posts []*Post
Replies []*PostReply
// Likes
LikedPostIDs map[string]bool
LikedReplyIDs map[string]bool
// Albums (hierarchical)
RootAlbum *Album
// Friends (Sone IDs)
Friends map[string]bool
// State
IsLocal bool // True if this is our own Sone
IsKnown bool // True if user has seen this Sone
// contains filtered or unexported fields
}
Sone represents a user profile in the Sone social network
func NewLocalSone ¶
NewLocalSone creates a new local Sone from a WoT identity
func ParseSoneXML ¶
ParseSoneXML parses XML data into a Sone object
func (*Sone) GetFingerprint ¶
GetFingerprint returns a hash representing the current state of this Sone
func (*Sone) IsPostLiked ¶
IsPostLiked checks if a post is liked
func (*Sone) IsReplyLiked ¶
IsReplyLiked checks if a reply is liked
func (*Sone) RemoveFriend ¶
RemoveFriend removes a friend from this Sone
func (*Sone) UnlikePost ¶
UnlikePost removes a post ID from liked posts
func (*Sone) UnlikeReply ¶
UnlikeReply removes a reply ID from liked replies
type SoneDownloader ¶
type SoneDownloader struct {
// contains filtered or unexported fields
}
SoneDownloader handles downloading remote Sones
func NewSoneDownloader ¶
func NewSoneDownloader(core *Core, sone *Sone) *SoneDownloader
NewSoneDownloader creates a new Sone downloader
type SoneInserter ¶
type SoneInserter struct {
// contains filtered or unexported fields
}
SoneInserter handles inserting a local Sone to Hyphanet
func NewSoneInserter ¶
func NewSoneInserter(core *Core, sone *Sone) *SoneInserter
NewSoneInserter creates a new Sone inserter
func (*SoneInserter) TriggerInsert ¶
func (si *SoneInserter) TriggerInsert()
TriggerInsert triggers an immediate insertion check
type SoneLinkPart ¶
SoneLinkPart represents a sone:// link
func (*SoneLinkPart) Text ¶
func (p *SoneLinkPart) Text() string
func (*SoneLinkPart) ToHTML ¶
func (p *SoneLinkPart) ToHTML() string
func (*SoneLinkPart) ToPlainText ¶
func (p *SoneLinkPart) ToPlainText() string
func (*SoneLinkPart) Type ¶
func (p *SoneLinkPart) Type() PartType
type SoneStatus ¶
type SoneStatus int
SoneStatus represents the current state of a Sone
const ( StatusUnknown SoneStatus = iota // Not yet downloaded StatusIdle // Not being downloaded or inserted StatusInserting // Currently being inserted StatusDownloading // Currently being downloaded )
func (SoneStatus) String ¶
func (s SoneStatus) String() string
type SoneXML ¶
type SoneXML struct {
XMLName xml.Name `xml:"sone"`
Time int64 `xml:"time"`
ProtocolVersion int `xml:"protocol-version"`
Client *ClientXML `xml:"client"`
Profile *ProfileXML `xml:"profile"`
Posts *PostsXML `xml:"posts"`
Replies *RepliesXML `xml:"replies"`
PostLikes *PostLikesXML `xml:"post-likes"`
ReplyLikes *ReplyLikesXML `xml:"reply-likes"`
Albums *AlbumsXML `xml:"albums,omitempty"`
}
SoneXML represents the XML structure for Sone data
type TextParser ¶
type TextParser struct {
// contains filtered or unexported fields
}
TextParser parses Sone text into parts
func NewTextParser ¶
func NewTextParser(soneResolver func(id string) *Sone, postResolver func(id string) *Post) *TextParser
NewTextParser creates a new text parser
func (*TextParser) Parse ¶
func (tp *TextParser) Parse(text string) []Part
Parse parses text into a slice of parts
type USKMonitor ¶
type USKMonitor struct {
// contains filtered or unexported fields
}
USKMonitor monitors USK updates for Sones
func NewUSKMonitor ¶
func NewUSKMonitor(core *Core) *USKMonitor
NewUSKMonitor creates a new USK monitor
func (*USKMonitor) SubscribeSone ¶
func (m *USKMonitor) SubscribeSone(soneID string) error
SubscribeSone subscribes to USK updates for a Sone
func (*USKMonitor) UnsubscribeSone ¶
func (m *USKMonitor) UnsubscribeSone(soneID string) error
UnsubscribeSone unsubscribes from USK updates for a Sone
type UploadStatus ¶
type UploadStatus int
UploadStatus represents the status of an image upload
const ( UploadPending UploadStatus = iota UploadInProgress UploadComplete UploadFailed )