Work on getting notes API
This commit is contained in:
parent
f656757710
commit
8a4c19dd17
9 changed files with 153 additions and 11 deletions
|
@ -8,5 +8,18 @@ type Emote struct {
|
|||
MetadataId string
|
||||
Name string
|
||||
// Server RemoteServer // `gorm:"foreignKey:ServerId;references:ID"`
|
||||
ServerId string
|
||||
ServerId uint
|
||||
}
|
||||
|
||||
func (s *Storage) GetEmoteById(id uint) (*Emote, error) {
|
||||
out := Emote{}
|
||||
err := s.db.First(&out, id).Error
|
||||
switch err {
|
||||
case nil:
|
||||
return &out, nil
|
||||
case gorm.ErrRecordNotFound:
|
||||
return nil, ErrEntryNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
10
storage/reactions.go
Normal file
10
storage/reactions.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
package storage
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Reaction struct {
|
||||
gorm.Model
|
||||
NoteId string
|
||||
ReactorId string
|
||||
EmoteId uint
|
||||
}
|
|
@ -168,8 +168,8 @@ func (s *Storage) FindAccountById(id string) (*Account, error) {
|
|||
}
|
||||
|
||||
log.Debug().Str("account-id", id).Msg("Didn't hit account in cache, checking db")
|
||||
acc = &Account{ID: id}
|
||||
res := s.db.First(acc)
|
||||
acc = &Account{}
|
||||
res := s.db.Where(Account{ID: id}).First(acc)
|
||||
if res.Error != nil {
|
||||
if errors.Is(res.Error, gorm.ErrRecordNotFound) {
|
||||
log.Warn().Str("account-id", id).Msg("Account not found")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue