sone

package
v0.0.0-...-840fb12 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package sone implements a Go port of the Sone social networking plugin for Hyphanet.

Index

Constants

View Source
const ClientName = "GoSone"

ClientName is the client name reported in Sone XML

View Source
const EventSoneUpdating = EventType(100)

EventSoneUpdating is published when a Sone update is detected

View Source
const ProtocolVersion = 0

ProtocolVersion is the Sone XML protocol version

View Source
const Version = "0.1.0"

Version is the GoSone client version

Variables

This section is empty.

Functions

func EscapeXML

func EscapeXML(s string) string

EscapeXML escapes special characters for XML

func FindMentionedSones

func FindMentionedSones(parts []Part) []string

FindMentionedSones finds all Sone IDs mentioned in parts

func HasMentionOf

func HasMentionOf(parts []Part, soneID string) bool

HasMentionOf checks if parts contain a mention of the given Sone ID

func RenderPartsToHTML

func RenderPartsToHTML(parts []Part) string

RenderPartsToHTML converts parts to HTML

func RenderPartsToPlainText

func RenderPartsToPlainText(parts []Part) string

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 NewAlbum

func NewAlbum(soneID string, title string) *Album

NewAlbum creates a new album

func NewRootAlbum

func NewRootAlbum(soneID string) *Album

NewRootAlbum creates a new root album for a Sone

func (*Album) AddAlbum

func (a *Album) AddAlbum(album *Album)

AddAlbum adds a nested album

func (*Album) AddImage

func (a *Album) AddImage(image *Image)

AddImage adds an image to the album

func (*Album) GetFingerprint

func (a *Album) GetFingerprint() string

GetFingerprint returns a hash of the album for change detection

func (*Album) IsEmpty

func (a *Album) IsEmpty() bool

IsEmpty returns true if the album has no content

func (*Album) RemoveAlbum

func (a *Album) RemoveAlbum(albumID string)

RemoveAlbum removes a nested album

func (*Album) RemoveImage

func (a *Album) RemoveImage(imageID string)

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 Client

type Client struct {
	Name    string
	Version string
}

Client represents the Sone client software info

type ClientXML

type ClientXML struct {
	Name    string `xml:"name"`
	Version string `xml:"version"`
}

ClientXML represents client info in XML

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

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default configuration

type Core

type Core struct {
	// contains filtered or unexported fields
}

Core is the main Sone application component

func NewCore

func NewCore(config *Config) *Core

NewCore creates a new Sone core instance

func (*Core) CreatePost

func (c *Core) CreatePost(soneID string, text string, recipientID *string) (*Post, error)

CreatePost creates a new post for a local Sone

func (*Core) CreateReply

func (c *Core) CreateReply(soneID string, postID string, text string) (*PostReply, error)

CreateReply creates a reply to a post

func (*Core) Database

func (c *Core) Database() Database

Database returns the database

func (*Core) DeletePost

func (c *Core) DeletePost(soneID string, postID string) error

DeletePost removes a post

func (*Core) DeleteReply

func (c *Core) DeleteReply(soneID string, replyID string) error

DeleteReply removes a reply

func (*Core) DismissNotification

func (c *Core) DismissNotification(id string)

DismissNotification dismisses a notification

func (*Core) EventBus

func (c *Core) EventBus() *EventBus

EventBus returns the event bus

func (*Core) FCPClient

func (c *Core) FCPClient() *fcp.Client

FCPClient returns the FCP client

func (*Core) FollowSone

func (c *Core) FollowSone(localSoneID string, remoteSoneID string) error

FollowSone adds a Sone to the follow list

func (*Core) GetAllSones

func (c *Core) GetAllSones() []*Sone

GetAllSones returns all known Sones

func (*Core) GetLocalSone

func (c *Core) GetLocalSone(id string) *Sone

GetLocalSone returns a local Sone by ID

func (*Core) GetLocalSones

func (c *Core) GetLocalSones() []*Sone

GetLocalSones returns all local Sones

func (*Core) GetNotifications

func (c *Core) GetNotifications() []*Notification

GetNotifications returns current notifications

func (*Core) GetPostFeed

func (c *Core) GetPostFeed(soneID string) []*Post

GetPostFeed returns posts for a Sone's feed

func (*Core) GetSone

func (c *Core) GetSone(id string) *Sone

GetSone returns a Sone by ID (local or remote)

func (*Core) LikePost

func (c *Core) LikePost(soneID string, postID string) error

LikePost likes a post

func (*Core) ProcessFetchedSone

func (c *Core) ProcessFetchedSone(soneID string, data []byte) error

ProcessFetchedSone processes a fetched Sone XML

func (*Core) Start

func (c *Core) Start() error

Start initializes and starts the Sone core

func (*Core) Stop

func (c *Core) Stop() error

Stop gracefully shuts down the Sone core

func (*Core) UnfollowSone

func (c *Core) UnfollowSone(localSoneID string, remoteSoneID string) error

UnfollowSone removes a Sone from the follow list

func (*Core) UnlikePost

func (c *Core) UnlikePost(soneID string, postID string) error

UnlikePost unlikes a post

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 NewEventBus

func NewEventBus() *EventBus

NewEventBus creates a new event bus

func (*EventBus) Publish

func (eb *EventBus) Publish(event Event)

Publish sends an event to all subscribed handlers

func (*EventBus) PublishMentionDetected

func (eb *EventBus) PublishMentionDetected(post *Post, mentionedSoneID string)

PublishMentionDetected publishes a mention detected event

func (*EventBus) PublishNewPostFound

func (eb *EventBus) PublishNewPostFound(post *Post)

PublishNewPostFound publishes a new post found event

func (*EventBus) PublishNewReplyFound

func (eb *EventBus) PublishNewReplyFound(reply *PostReply)

PublishNewReplyFound publishes a new reply found event

func (*EventBus) PublishPostRemoved

func (eb *EventBus) PublishPostRemoved(post *Post)

PublishPostRemoved publishes a post removed event

func (*EventBus) PublishReplyRemoved

func (eb *EventBus) PublishReplyRemoved(reply *PostReply)

PublishReplyRemoved publishes a reply removed event

func (*EventBus) PublishSoneDiscovered

func (eb *EventBus) PublishSoneDiscovered(sone *Sone)

PublishSoneDiscovered publishes a new Sone discovered event

func (*EventBus) PublishSoneInsertAborted

func (eb *EventBus) PublishSoneInsertAborted(sone *Sone, reason string)

PublishSoneInsertAborted publishes a Sone insert aborted event

func (*EventBus) PublishSoneInserted

func (eb *EventBus) PublishSoneInserted(sone *Sone, edition int64)

PublishSoneInserted publishes a Sone inserted event

func (*EventBus) PublishSoneInserting

func (eb *EventBus) PublishSoneInserting(sone *Sone)

PublishSoneInserting publishes a Sone inserting event

func (*EventBus) PublishSoneUpdated

func (eb *EventBus) PublishSoneUpdated(sone *Sone)

PublishSoneUpdated publishes a Sone updated event

func (*EventBus) Start

func (eb *EventBus) Start()

Start begins async event processing

func (*EventBus) Stop

func (eb *EventBus) Stop()

Stop stops async event processing

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 EventHandler

type EventHandler func(Event)

EventHandler is a function that handles events

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 Field

type Field struct {
	ID    string
	Name  string
	Value string
}

Field represents a custom profile field

type FieldXML

type FieldXML struct {
	Name  string `xml:"field-name"`
	Value string `xml:"field-value"`
}

FieldXML represents a single profile field

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

type HTTPLinkPart struct {
	URL         string
	DisplayText string
}

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 NewImage

func NewImage(soneID string) *Image

NewImage creates a new image

func (*Image) GetFingerprint

func (i *Image) GetFingerprint() string

GetFingerprint returns a hash of the image for change detection

func (*Image) IsInserted

func (i *Image) IsInserted() bool

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

func (m *ImageManager) CreateAlbum(soneID string, title string, parentID string) (*Album, error)

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 Part

type Part interface {
	Type() PartType
	Text() string
	ToHTML() string
	ToPlainText() string
}

Part represents a parsed piece of text

type PartType

type PartType int

PartType represents the type of parsed text part

const (
	PartPlainText PartType = iota
	PartFreenetLink
	PartSoneLink
	PartPostLink
	PartHTTPLink
	PartFreemail
)

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 NewPost

func NewPost(soneID string, text string) *Post

NewPost creates a new post

func (*Post) GetFingerprint

func (p *Post) GetFingerprint() string

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

type PostLinkPart struct {
	PostID     string
	PostAuthor string // Resolved author name if available
}

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

func NewPostReply(soneID string, postID string, text string) *PostReply

NewPostReply creates a new reply

func (*PostReply) GetFingerprint

func (r *PostReply) GetFingerprint() string

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 NewProfile

func NewProfile() *Profile

NewProfile creates a new empty profile

func (*Profile) AddField

func (p *Profile) AddField(name string) *Field

AddField adds a new field to the profile

func (*Profile) GetFieldByName

func (p *Profile) GetFieldByName(name string) *Field

GetFieldByName returns a field by name

func (*Profile) GetFingerprint

func (p *Profile) GetFingerprint() string

GetFingerprint returns a hash of the profile for change detection

func (*Profile) RemoveField

func (p *Profile) RemoveField(fieldID string)

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

func NewLocalSone(identity *wot.Identity) *Sone

NewLocalSone creates a new local Sone from a WoT identity

func NewSone

func NewSone(id string) *Sone

NewSone creates a new Sone with the given ID

func ParseSoneXML

func ParseSoneXML(data []byte, soneID string) (*Sone, error)

ParseSoneXML parses XML data into a Sone object

func (*Sone) AddFriend

func (s *Sone) AddFriend(soneID string)

AddFriend adds a friend to this Sone

func (*Sone) GetFingerprint

func (s *Sone) GetFingerprint() string

GetFingerprint returns a hash representing the current state of this Sone

func (*Sone) HasFriend

func (s *Sone) HasFriend(soneID string) bool

HasFriend checks if this Sone has the given Sone ID as a friend

func (*Sone) IsPostLiked

func (s *Sone) IsPostLiked(postID string) bool

IsPostLiked checks if a post is liked

func (*Sone) IsReplyLiked

func (s *Sone) IsReplyLiked(replyID string) bool

IsReplyLiked checks if a reply is liked

func (*Sone) LikePost

func (s *Sone) LikePost(postID string)

LikePost adds a post ID to liked posts

func (*Sone) LikeReply

func (s *Sone) LikeReply(replyID string)

LikeReply adds a reply ID to liked replies

func (*Sone) RemoveFriend

func (s *Sone) RemoveFriend(soneID string)

RemoveFriend removes a friend from this Sone

func (*Sone) ToXML

func (s *Sone) ToXML(clientName, clientVersion string) ([]byte, error)

ToXML serializes a Sone to XML for insertion

func (*Sone) UnlikePost

func (s *Sone) UnlikePost(postID string)

UnlikePost removes a post ID from liked posts

func (*Sone) UnlikeReply

func (s *Sone) UnlikeReply(replyID string)

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

func (*SoneDownloader) Start

func (sd *SoneDownloader) Start()

Start begins the download loop

func (*SoneDownloader) Stop

func (sd *SoneDownloader) Stop()

Stop stops the 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) Start

func (si *SoneInserter) Start()

Start begins the insertion loop

func (*SoneInserter) Stop

func (si *SoneInserter) Stop()

Stop stops the inserter

func (*SoneInserter) TriggerInsert

func (si *SoneInserter) TriggerInsert()

TriggerInsert triggers an immediate insertion check

type SoneLinkPart

type SoneLinkPart struct {
	SoneID   string
	SoneName string // Resolved name if available
}

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) Start

func (m *USKMonitor) Start() error

Start begins monitoring USKs

func (*USKMonitor) Stop

func (m *USKMonitor) Stop()

Stop stops the 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
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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