this repo has no description
0
fork

Configure Feed

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

add json serialization names to db models

This is "just in case" these end up directly part of public APIs (eg,
via admin endpoints)

+22 -22
+22 -22
cmd/relay/relay/models/models.go
··· 5 5 ) 6 6 7 7 type DomainBan struct { 8 - ID uint64 `gorm:"column:id;primarykey"` 8 + ID uint64 `gorm:"column:id;primarykey" json:"id"` 9 9 // CreatedAt is automatically managed by gorm (by convention) 10 - CreatedAt time.Time 10 + CreatedAt time.Time `json:"createdAt"` 11 11 12 - Domain string `gorm:"unique"` 12 + Domain string `gorm:"unique" json:"domain"` 13 13 } 14 14 15 15 type HostStatus string ··· 23 23 ) 24 24 25 25 type Host struct { 26 - ID uint64 `gorm:"column:id;primarykey"` 26 + ID uint64 `gorm:"column:id;primarykey" json:"id"` 27 27 28 28 // these fields are automatically managed by gorm (by convention) 29 - CreatedAt time.Time 30 - UpdatedAt time.Time 29 + CreatedAt time.Time `json:"createdAt"` 30 + UpdatedAt time.Time `json:"updatedAt"` 31 31 32 32 // hostname, without URL scheme. if localhost, must include a port number; otherwise must not include port 33 - Hostname string `gorm:"column:hostname;uniqueIndex;not null"` 33 + Hostname string `gorm:"column:hostname;uniqueIndex;not null" json:"hostname"` 34 34 35 35 // indicates ws:// not wss:// 36 - NoSSL bool `gorm:"column:no_ssl;default:false"` 36 + NoSSL bool `gorm:"column:no_ssl;default:false" json:"noSSL"` 37 37 38 38 // maximum number of active accounts 39 - AccountLimit int64 `gorm:"column:account_limit"` 39 + AccountLimit int64 `gorm:"column:account_limit" json:"accountLimit"` 40 40 41 41 // indicates this is a highly trusted host (PDS), and different rate limits apply 42 - Trusted bool `gorm:"column:trusted;default:false"` 42 + Trusted bool `gorm:"column:trusted;default:false" json:"trusted"` 43 43 44 - Status HostStatus `gorm:"column:status;default:active"` 44 + Status HostStatus `gorm:"column:status;default:active" json:"status"` 45 45 46 46 // the last sequence number persisted for this host. updated periodically, and at shutdown. negative number indicates no sequence recorded 47 - LastSeq int64 `gorm:"column:last_seq;default:-1"` 47 + LastSeq int64 `gorm:"column:last_seq;default:-1" json:"lastSeq"` 48 48 49 49 // represents the number of accounts on the host, minus any in "deleted" state 50 - AccountCount int64 `gorm:"column:account_count;default:0"` 50 + AccountCount int64 `gorm:"column:account_count;default:0" json:"accountCount"` 51 51 } 52 52 53 53 func (Host) TableName() string { ··· 73 73 ) 74 74 75 75 type Account struct { 76 - UID uint64 `gorm:"column:uid;primarykey"` 77 - DID string `gorm:"column:did;uniqueIndex;not null"` 76 + UID uint64 `gorm:"column:uid;primarykey" json:"uid"` 77 + DID string `gorm:"column:did;uniqueIndex;not null" json:"did"` 78 78 79 79 // this is a reference to the ID field on Host; but it is not an explicit foreign key 80 - HostID uint64 `gorm:"column:host_id;not null"` 81 - Status AccountStatus `gorm:"column:status;not null;default:active"` 82 - UpstreamStatus AccountStatus `gorm:"column:upstream_status;not null;default:active"` 80 + HostID uint64 `gorm:"column:host_id;not null" json:"hostID"` 81 + Status AccountStatus `gorm:"column:status;not null;default:active" json:"status"` 82 + UpstreamStatus AccountStatus `gorm:"column:upstream_status;not null;default:active" json:"upstreamStatus"` 83 83 } 84 84 85 85 func (Account) TableName() string { ··· 89 89 // This is a small extension table to `Account`, which holds fast-changing fields updated on every firehose event. 90 90 type AccountRepo struct { 91 91 // references Account.UID, but not set up as a foreign key 92 - UID uint64 `gorm:"column:uid;primarykey"` 93 - Rev string `gorm:"column:rev;not null"` 92 + UID uint64 `gorm:"column:uid;primarykey" json:"uid"` 93 + Rev string `gorm:"column:rev;not null" json:"rev"` 94 94 95 95 // The CID of the entire signed commit block. Sometimes called the "head" 96 - CommitCID string `gorm:"column:commit_cid;not null"` 96 + CommitCID string `gorm:"column:commit_cid;not null" json:"commitCID"` 97 97 98 98 // The CID of the top of the repo MST, which is the 'data' field within the commit block. This becomes 'prevData' 99 - CommitDataCID string `gorm:"column:commit_data_cid;not null"` 99 + CommitDataCID string `gorm:"column:commit_data_cid;not null" json:"commitDataCID"` 100 100 } 101 101 102 102 func (AccountRepo) TableName() string {