super basic

This commit is contained in:
Karmanyaah Malhotra
2021-02-21 00:58:50 -05:00
parent eafc18099d
commit 7cb9983da8
17 changed files with 965 additions and 926 deletions

View File

@ -53,8 +53,8 @@ func (pq *PuppetQuery) GetAll() (puppets []*Puppet) {
func (pq *PuppetQuery) Get(jid types.GroupMeID) *Puppet {
puppet := Puppet{}
ans := pq.db.Where("jid = ?", jid).Take(puppet)
if ans.Error != nil {
ans := pq.db.Where("jid = ?", jid).Limit(1).Find(&puppet)
if ans.Error != nil || ans.RowsAffected == 0 {
return nil
}
return &puppet
@ -62,8 +62,8 @@ func (pq *PuppetQuery) Get(jid types.GroupMeID) *Puppet {
func (pq *PuppetQuery) GetByCustomMXID(mxid id.UserID) *Puppet {
puppet := Puppet{}
ans := pq.db.Where("custom_mxid = ?", mxid).Take(puppet)
if ans.Error != nil {
ans := pq.db.Where("custom_mxid = ?", mxid).Limit(1).Find(&puppet)
if ans.Error != nil || ans.RowsAffected == 0 {
return nil
}
return &puppet
@ -93,7 +93,7 @@ type Puppet struct {
Displayname string
NameQuality int8
CustomMXID id.UserID
CustomMXID id.UserID `gorm:"column:custom_mxid;"`
AccessToken string
NextBatch string
EnablePresence bool `gorm:"notNull;default:true"`