Add a bunch of new logging
This commit is contained in:
@ -129,10 +129,9 @@ func (msg *Message) encodeBinaryContent() []byte {
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
func (msg *Message) Insert() error {
|
||||
func (msg *Message) Insert() {
|
||||
_, err := msg.db.Exec("INSERT INTO message VALUES (?, ?, ?, ?, ?, ?)", msg.Chat.JID, msg.Chat.Receiver, msg.JID, msg.MXID, msg.Sender, msg.encodeBinaryContent())
|
||||
if err != nil {
|
||||
msg.log.Warnfln("Failed to insert %s@%s: %v", msg.Chat, msg.JID, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -142,16 +142,15 @@ func (portal *Portal) mxidPtr() *string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (portal *Portal) Insert() error {
|
||||
func (portal *Portal) Insert() {
|
||||
_, err := portal.db.Exec("INSERT INTO portal VALUES (?, ?, ?, ?, ?, ?)",
|
||||
portal.Key.JID, portal.Key.Receiver, portal.mxidPtr(), portal.Name, portal.Topic, portal.Avatar)
|
||||
if err != nil {
|
||||
portal.log.Warnfln("Failed to insert %s: %v", portal.Key, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (portal *Portal) Update() error {
|
||||
func (portal *Portal) Update() {
|
||||
var mxid *string
|
||||
if len(portal.MXID) > 0 {
|
||||
mxid = &portal.MXID
|
||||
@ -161,5 +160,4 @@ func (portal *Portal) Update() error {
|
||||
if err != nil {
|
||||
portal.log.Warnfln("Failed to update %s: %v", portal.Key, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -92,20 +92,18 @@ func (puppet *Puppet) Scan(row Scannable) *Puppet {
|
||||
return puppet
|
||||
}
|
||||
|
||||
func (puppet *Puppet) Insert() error {
|
||||
func (puppet *Puppet) Insert() {
|
||||
_, err := puppet.db.Exec("INSERT INTO puppet VALUES (?, ?, ?, ?)",
|
||||
puppet.JID, puppet.Avatar, puppet.Displayname, puppet.NameQuality)
|
||||
if err != nil {
|
||||
puppet.log.Warnfln("Failed to insert %s: %v", puppet.JID, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (puppet *Puppet) Update() error {
|
||||
func (puppet *Puppet) Update() {
|
||||
_, err := puppet.db.Exec("UPDATE puppet SET displayname=?, name_quality=?, avatar=? WHERE jid=?",
|
||||
puppet.Displayname, puppet.NameQuality, puppet.Avatar, puppet.JID)
|
||||
if err != nil {
|
||||
puppet.log.Warnfln("Failed to update %s->%s: %v", puppet.JID, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ func (user *User) sessionUnptr() (sess whatsapp.Session) {
|
||||
return
|
||||
}
|
||||
|
||||
func (user *User) Insert() error {
|
||||
func (user *User) Insert() {
|
||||
sess := user.sessionUnptr()
|
||||
_, err := user.db.Exec("INSERT INTO user VALUES (?, ?, ?, ?, ?, ?, ?, ?)", user.MXID, user.jidPtr(),
|
||||
user.ManagementRoom,
|
||||
@ -156,10 +156,9 @@ func (user *User) Insert() error {
|
||||
if err != nil {
|
||||
user.log.Warnfln("Failed to insert %s: %v", user.MXID, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (user *User) Update() error {
|
||||
func (user *User) Update() {
|
||||
sess := user.sessionUnptr()
|
||||
_, err := user.db.Exec("UPDATE user SET jid=?, management_room=?, client_id=?, client_token=?, server_token=?, enc_key=?, mac_key=? WHERE mxid=?",
|
||||
user.jidPtr(), user.ManagementRoom,
|
||||
@ -168,5 +167,4 @@ func (user *User) Update() error {
|
||||
if err != nil {
|
||||
user.log.Warnfln("Failed to update %s: %v", user.MXID, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user