this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(data): add source metadata fields to models

Add SourceType, SourceNetwork, SourceChannel, SourceUserID,
and SourceUserName fields to IRCLink, Image, Quote, and
TimelineItem structs. Add SourceFilter type with IsEmpty
method. This enables multi-source support for tracking where
content originates (IRC, Discord, Slack, etc.).

+57 -27
+57 -27
internal/data/store.go
··· 6 6 ) 7 7 8 8 type IRCLink struct { 9 - ID int `json:"ircLinkID" gorm:"column:ircLinkID;primaryKey"` 10 - Timestamp time.Time `json:"timestamp" gorm:"column:timestamp"` 11 - User string `json:"user" gorm:"column:user;index"` 12 - Title string `json:"title" gorm:"column:title"` 13 - URL string `json:"url" gorm:"column:url"` 14 - Clicks int `json:"clicks" gorm:"column:clicks;default:0"` 15 - ContentType string `json:"content_type" gorm:"column:content_type"` 9 + ID int `json:"ircLinkID" gorm:"column:ircLinkID;primaryKey"` 10 + Timestamp time.Time `json:"timestamp" gorm:"column:timestamp"` 11 + User string `json:"user" gorm:"column:user;index"` 12 + Title string `json:"title" gorm:"column:title"` 13 + URL string `json:"url" gorm:"column:url"` 14 + Clicks int `json:"clicks" gorm:"column:clicks;default:0"` 15 + ContentType string `json:"content_type" gorm:"column:content_type"` 16 + SourceType *string `json:"source_type,omitempty" gorm:"column:source_type;type:varchar(50);index:idx_source,priority:1"` 17 + SourceNetwork *string `json:"source_network,omitempty" gorm:"column:source_network;type:varchar(255);index:idx_source,priority:2"` 18 + SourceChannel *string `json:"source_channel,omitempty" gorm:"column:source_channel;type:varchar(255);index:idx_source,priority:3"` 19 + SourceUserID *string `json:"source_user_id,omitempty" gorm:"column:source_user_id;type:varchar(255)"` 20 + SourceUserName *string `json:"source_user_name,omitempty" gorm:"column:source_user_name;type:varchar(255)"` 16 21 } 17 22 18 23 // TableName overrides the table name used by User to `ircLink` ··· 21 26 } 22 27 23 28 type Image struct { 24 - ID int `json:"imageID" gorm:"column:imageID;primaryKey"` 25 - Timestamp time.Time `json:"timestamp" gorm:"column:timestamp"` 26 - Title string `json:"title" gorm:"column:title"` 27 - Link string `json:"link" gorm:"column:link"` 28 - URL string `json:"url" gorm:"column:url"` 29 - MD5Sum string `json:"md5sum" gorm:"column:md5sum"` 29 + ID int `json:"imageID" gorm:"column:imageID;primaryKey"` 30 + Timestamp time.Time `json:"timestamp" gorm:"column:timestamp"` 31 + Title string `json:"title" gorm:"column:title"` 32 + Link string `json:"link" gorm:"column:link"` 33 + URL string `json:"url" gorm:"column:url"` 34 + MD5Sum string `json:"md5sum" gorm:"column:md5sum"` 35 + SourceType *string `json:"source_type,omitempty" gorm:"column:source_type;type:varchar(50);index:idx_source,priority:1"` 36 + SourceNetwork *string `json:"source_network,omitempty" gorm:"column:source_network;type:varchar(255);index:idx_source,priority:2"` 37 + SourceChannel *string `json:"source_channel,omitempty" gorm:"column:source_channel;type:varchar(255);index:idx_source,priority:3"` 38 + SourceUserID *string `json:"source_user_id,omitempty" gorm:"column:source_user_id;type:varchar(255)"` 39 + SourceUserName *string `json:"source_user_name,omitempty" gorm:"column:source_user_name;type:varchar(255)"` 30 40 } 31 41 32 42 // TableName overrides the table name used by User to `image` ··· 35 45 } 36 46 37 47 type Quote struct { 38 - ID int `json:"quoteID" gorm:"column:quoteID;primaryKey"` 39 - Timestamp time.Time `json:"timestamp" gorm:"column:timestamp"` 40 - Quote string `json:"quote" gorm:"column:quote"` 41 - Author string `json:"author" gorm:"column:author;type:varchar(255);index"` 42 - Poster string `json:"poster,omitempty" gorm:"column:poster;type:varchar(255);index"` 48 + ID int `json:"quoteID" gorm:"column:quoteID;primaryKey"` 49 + Timestamp time.Time `json:"timestamp" gorm:"column:timestamp"` 50 + Quote string `json:"quote" gorm:"column:quote"` 51 + Author string `json:"author" gorm:"column:author;type:varchar(255);index"` 52 + Poster string `json:"poster,omitempty" gorm:"column:poster;type:varchar(255);index"` 53 + SourceType *string `json:"source_type,omitempty" gorm:"column:source_type;type:varchar(50);index:idx_source,priority:1"` 54 + SourceNetwork *string `json:"source_network,omitempty" gorm:"column:source_network;type:varchar(255);index:idx_source,priority:2"` 55 + SourceChannel *string `json:"source_channel,omitempty" gorm:"column:source_channel;type:varchar(255);index:idx_source,priority:3"` 56 + SourceUserID *string `json:"source_user_id,omitempty" gorm:"column:source_user_id;type:varchar(255)"` 57 + SourceUserName *string `json:"source_user_name,omitempty" gorm:"column:source_user_name;type:varchar(255)"` 43 58 } 44 59 45 60 // TableName overrides the table name used by User to `quote` ··· 54 69 } 55 70 56 71 type TimelineItem struct { 57 - Type string `json:"type"` // "link", "quote", or "image" 58 - ID int `json:"id"` 59 - Timestamp time.Time `json:"timestamp"` 60 - Title string `json:"title"` // For links and images 61 - URL string `json:"url"` // For links and images 62 - Content string `json:"content"` // For quotes 63 - Author string `json:"author"` // For quotes (and links/images as User) 64 - MD5Sum string `json:"md5sum"` // For images 65 - ContentType string `json:"contentType" gorm:"column:content_type"` // For links (to detect images) 72 + Type string `json:"type"` // "link", "quote", or "image" 73 + ID int `json:"id"` 74 + Timestamp time.Time `json:"timestamp"` 75 + Title string `json:"title"` // For links and images 76 + URL string `json:"url"` // For links and images 77 + Content string `json:"content"` // For quotes 78 + Author string `json:"author"` // For quotes (and links/images as User) 79 + MD5Sum string `json:"md5sum"` // For images 80 + ContentType string `json:"contentType" gorm:"column:content_type"` // For links (to detect images) 81 + SourceType *string `json:"source_type,omitempty"` 82 + SourceNetwork *string `json:"source_network,omitempty"` 83 + SourceChannel *string `json:"source_channel,omitempty"` 84 + SourceUserID *string `json:"source_user_id,omitempty"` 85 + SourceUserName *string `json:"source_user_name,omitempty"` 86 + } 87 + 88 + type SourceFilter struct { 89 + SourceType *string 90 + SourceNetwork *string 91 + SourceChannel *string 92 + } 93 + 94 + func (f SourceFilter) IsEmpty() bool { 95 + return f.SourceType == nil && f.SourceNetwork == nil && f.SourceChannel == nil 66 96 } 67 97 68 98 type Tag struct {