user: send errUserNotLoggedIn if we can't bridge event from logged-out user (#204)
This commit is contained in:
23
portal.go
23
portal.go
@@ -1522,10 +1522,16 @@ func (portal *Portal) RefererOptIfUser(sess *discordgo.Session, threadID string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) {
|
func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) {
|
||||||
if portal.IsPrivateChat() && sender.DiscordID != portal.Key.Receiver {
|
if portal.IsPrivateChat() {
|
||||||
|
if !sender.IsLoggedIn() {
|
||||||
|
go portal.sendMessageMetrics(evt, errUserNotLoggedIn, "Ignoring")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if sender.DiscordID != portal.Key.Receiver {
|
||||||
go portal.sendMessageMetrics(evt, errUserNotReceiver, "Ignoring")
|
go portal.sendMessageMetrics(evt, errUserNotReceiver, "Ignoring")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
content, ok := evt.Content.Parsed.(*event.MessageEventContent)
|
content, ok := evt.Content.Parsed.(*event.MessageEventContent)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -1918,12 +1924,13 @@ func (portal *Portal) getMatrixUsers() ([]id.UserID, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (portal *Portal) handleMatrixReaction(sender *User, evt *event.Event) {
|
func (portal *Portal) handleMatrixReaction(sender *User, evt *event.Event) {
|
||||||
|
if !sender.IsLoggedIn() {
|
||||||
|
go portal.sendMessageMetrics(evt, errUserNotLoggedIn, "Ignoring")
|
||||||
|
return
|
||||||
|
}
|
||||||
if portal.IsPrivateChat() && sender.DiscordID != portal.Key.Receiver {
|
if portal.IsPrivateChat() && sender.DiscordID != portal.Key.Receiver {
|
||||||
go portal.sendMessageMetrics(evt, errUserNotReceiver, "Ignoring")
|
go portal.sendMessageMetrics(evt, errUserNotReceiver, "Ignoring")
|
||||||
return
|
return
|
||||||
} else if !sender.IsLoggedIn() {
|
|
||||||
//go portal.sendMessageMetrics(evt, errReactionUserNotLoggedIn, "Ignoring")
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reaction := evt.Content.AsReaction()
|
reaction := evt.Content.AsReaction()
|
||||||
@@ -2101,10 +2108,16 @@ func (portal *Portal) handleDiscordReaction(user *User, reaction *discordgo.Mess
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (portal *Portal) handleMatrixRedaction(sender *User, evt *event.Event) {
|
func (portal *Portal) handleMatrixRedaction(sender *User, evt *event.Event) {
|
||||||
if portal.IsPrivateChat() && sender.DiscordID != portal.Key.Receiver {
|
if portal.IsPrivateChat() {
|
||||||
|
if !sender.IsLoggedIn() {
|
||||||
|
go portal.sendMessageMetrics(evt, errUserNotLoggedIn, "Ignoring")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if sender.DiscordID != portal.Key.Receiver {
|
||||||
go portal.sendMessageMetrics(evt, errUserNotReceiver, "Ignoring")
|
go portal.sendMessageMetrics(evt, errUserNotReceiver, "Ignoring")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sess := sender.Session
|
sess := sender.Session
|
||||||
if sess == nil && portal.RelayWebhookID == "" {
|
if sess == nil && portal.RelayWebhookID == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user