🐛 Bug fixes in unable get accurate avatar & banner url
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/samber/lo"
|
||||
"github.com/spf13/viper"
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
@ -38,6 +40,20 @@ type Account struct {
|
||||
RelatedFriendships []AccountFriendship `json:"related_friendships" gorm:"foreignKey:RelatedID"`
|
||||
}
|
||||
|
||||
func (v Account) GetAvatar() *string {
|
||||
if v.Avatar != nil {
|
||||
return lo.ToPtr(fmt.Sprintf("%s/api/attachments/%d", viper.GetString("paperclip.endpoint"), *v.Avatar))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v Account) GetBanner() *string {
|
||||
if v.Banner != nil {
|
||||
return lo.ToPtr(fmt.Sprintf("%s/api/attachments/%d", viper.GetString("paperclip.endpoint"), *v.Banner))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v Account) GetPrimaryEmail() AccountContact {
|
||||
val, _ := lo.Find(v.Contacts, func(item AccountContact) bool {
|
||||
return item.Type == EmailAccountContact && item.IsPrimary
|
||||
|
Reference in New Issue
Block a user