Reactions groupme -> Matrix
finalizing
This commit is contained in:
parent
086cff7244
commit
36d40136fb
@ -6,6 +6,9 @@
|
|||||||
* [ ] Media/files
|
* [ ] Media/files
|
||||||
* [ ] Replies
|
* [ ] Replies
|
||||||
* [ ] Message redactions
|
* [ ] Message redactions
|
||||||
|
* [ ] Reactions
|
||||||
|
* [ ] Addition
|
||||||
|
* [ ] Deletion
|
||||||
* [ ] Presence - N/A
|
* [ ] Presence - N/A
|
||||||
* [ ] Typing notifications
|
* [ ] Typing notifications
|
||||||
* [ ] Read receipts
|
* [ ] Read receipts
|
||||||
@ -41,6 +44,9 @@
|
|||||||
* [ ] Events created
|
* [ ] Events created
|
||||||
* [ ] Events modified
|
* [ ] Events modified
|
||||||
* [ ] Going/Not
|
* [ ] Going/Not
|
||||||
|
* [ ] Reactions
|
||||||
|
* [x] Addition
|
||||||
|
* [ ] Deletion <sup>[3]</sup>
|
||||||
* [ ] Admin/superadmin status
|
* [ ] Admin/superadmin status
|
||||||
* [ ] Membership actions
|
* [ ] Membership actions
|
||||||
* [ ] Invite
|
* [ ] Invite
|
||||||
|
@ -20,7 +20,7 @@ func (mq *ReactionQuery) New() *Reaction {
|
|||||||
|
|
||||||
func (mq *ReactionQuery) GetByJID(jid types.GroupMeID) (reactions []*Reaction) {
|
func (mq *ReactionQuery) GetByJID(jid types.GroupMeID) (reactions []*Reaction) {
|
||||||
ans := mq.db.Model(&Reaction{}).
|
ans := mq.db.Model(&Reaction{}).
|
||||||
Joins("Users"). // TODO: Do this in seperate function?
|
Preload("Puppet"). // TODO: Do this in seperate function?
|
||||||
Where("message_jid = ?", jid).
|
Where("message_jid = ?", jid).
|
||||||
Limit(1).Find(&reactions)
|
Limit(1).Find(&reactions)
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ type Reaction struct {
|
|||||||
Message Message `gorm:"foreignKey:MessageMXID,MessageJID;references:MXID,JID;"`
|
Message Message `gorm:"foreignKey:MessageMXID,MessageJID;references:MXID,JID;"`
|
||||||
|
|
||||||
//User
|
//User
|
||||||
UserMXID id.UserID `gorm:"notNull"`
|
PuppetJID types.GroupMeID `gorm:"notNull"`
|
||||||
User User `gorm:"foreignKey:UserMXID;references:MXID;"`
|
Puppet Puppet `gorm:"foreignKey:PuppetJID;references:jid;"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (reaction *Reaction) Insert() {
|
func (reaction *Reaction) Insert() {
|
||||||
|
14
portal.go
14
portal.go
@ -1608,10 +1608,6 @@ func (portal *Portal) handleReaction(msgID types.GroupMeID, ppl []types.GroupMeI
|
|||||||
}
|
}
|
||||||
eventID = message.MXID
|
eventID = message.MXID
|
||||||
}
|
}
|
||||||
for _, i := range reactions {
|
|
||||||
fmt.Printf("%+v, ", i.User)
|
|
||||||
}
|
|
||||||
fmt.Println(newLikes, ppl)
|
|
||||||
|
|
||||||
for _, jid := range newLikes {
|
for _, jid := range newLikes {
|
||||||
intent := portal.getReactionIntent(jid)
|
intent := portal.getReactionIntent(jid)
|
||||||
@ -1625,18 +1621,18 @@ func (portal *Portal) handleReaction(msgID types.GroupMeID, ppl []types.GroupMeI
|
|||||||
newReaction.MXID = resp.EventID
|
newReaction.MXID = resp.EventID
|
||||||
newReaction.MessageJID = msgID
|
newReaction.MessageJID = msgID
|
||||||
newReaction.MessageMXID = eventID
|
newReaction.MessageMXID = eventID
|
||||||
newReaction.UserMXID = portal.bridge.GetPuppetByJID(jid).MXID
|
newReaction.PuppetJID = jid
|
||||||
|
|
||||||
newReaction.Insert()
|
newReaction.Insert()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, reaction := range removeLikes {
|
for _, reaction := range removeLikes {
|
||||||
if len(reaction.User.JID) == 0 {
|
if len(reaction.Puppet.JID) == 0 {
|
||||||
portal.log.Warnln("Reaction user state wrong", reaction.MXID, msgID)
|
portal.log.Warnln("Reaction user state wrong", reaction.MXID, msgID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
intent := portal.getReactionIntent(reaction.User.JID)
|
intent := portal.getReactionIntent(reaction.PuppetJID)
|
||||||
_, err := intent.RedactEvent(portal.MXID, reaction.MXID)
|
_, err := intent.RedactEvent(portal.MXID, reaction.MXID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
portal.log.Errorln("Something wrong with reaction redaction", reaction.MXID)
|
portal.log.Errorln("Something wrong with reaction redaction", reaction.MXID)
|
||||||
@ -1651,7 +1647,7 @@ func oldReactions(a []*database.Reaction, b []string) (ans []*database.Reaction)
|
|||||||
for _, i := range a {
|
for _, i := range a {
|
||||||
flag := false
|
flag := false
|
||||||
for _, j := range b {
|
for _, j := range b {
|
||||||
if i.User.JID == j {
|
if i.PuppetJID == j {
|
||||||
flag = true
|
flag = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1668,7 +1664,7 @@ func newReactions(a []*database.Reaction, b []string) (ans []string) {
|
|||||||
for _, j := range b {
|
for _, j := range b {
|
||||||
flag := false
|
flag := false
|
||||||
for _, i := range a {
|
for _, i := range a {
|
||||||
if i.User.JID == j {
|
if i.PuppetJID == j {
|
||||||
flag = true
|
flag = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user