Kinda work dms

This commit is contained in:
Karmanyaah Malhotra
2021-04-27 22:49:01 -04:00
parent b35a6be635
commit 0ff534c2df
7 changed files with 155 additions and 106 deletions

View File

@@ -24,6 +24,8 @@ import (
"github.com/karmanyaahm/matrix-groupme-go/types"
)
// JID is the puppet or the group
// Receiver is the "Other Person" in a DM or the group itself in a group
type PortalKey struct {
JID types.GroupMeID `gorm:"primaryKey"`
Receiver types.GroupMeID `gorm:"primaryKey"`
@@ -50,6 +52,11 @@ func (key PortalKey) String() string {
return key.JID + "-" + key.Receiver
}
func (key PortalKey) IsPrivate() bool {
//also see FindPrivateChats
return key.JID != key.Receiver
}
type PortalQuery struct {
db *Database
log log.Logger
@@ -82,8 +89,8 @@ func (pq *PortalQuery) GetAllByJID(jid types.GroupMeID) []*Portal {
}
func (pq *PortalQuery) FindPrivateChats(receiver types.GroupMeID) []*Portal {
print("aaaaaaaaaaaaaaaaaa wrong portal stuff")
return pq.getAll(pq.db.DB.Where("receiver = ? AND jid LIKE '%@s.whatsapp.net'", receiver))
//also see IsPrivate
return pq.getAll(pq.db.DB.Where("receiver = ? AND receiver <> jid", receiver))
}