Compare commits
2 Commits
22fe1cac46
...
a847ba5cdd
| Author | SHA1 | Date | |
|---|---|---|---|
| a847ba5cdd | |||
| d5ec58be68 |
65
main.go
65
main.go
@@ -33,6 +33,7 @@ import (
|
||||
"mellium.im/xmpp/bookmarks"
|
||||
"mellium.im/xmpp/jid"
|
||||
"mellium.im/xmpp/muc"
|
||||
"mellium.im/xmpp/pubsub"
|
||||
oasisSdk "github.com/sunglocto/oasis-sdk"
|
||||
// TODO: integrated theme switcher
|
||||
)
|
||||
@@ -45,6 +46,7 @@ var replyNameIcon string = ">"
|
||||
var replyBodyIcon string = ">"
|
||||
var newlineIcon string = " |-> "
|
||||
var agreesToSendingHotFuckIntoChannel bool = false
|
||||
var OccupantIdsToBlock = make(map[string]string)
|
||||
|
||||
// by sunglocto
|
||||
// license AGPL
|
||||
@@ -182,6 +184,7 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
return container.NewVBox(replytext, container.NewHBox(ico, author), content, btn, reactions)
|
||||
},
|
||||
func(i widget.ListItemID, co fyne.CanvasObject) {
|
||||
|
||||
vbox := co.(*fyne.Container)
|
||||
authorBox := vbox.Objects[1].(*fyne.Container)
|
||||
replytext := vbox.Objects[0].(*widget.Label)
|
||||
@@ -198,6 +201,21 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
|
||||
author := authorBox.Objects[1].(*widget.Label)
|
||||
content := vbox.Objects[2].(*widget.Label)
|
||||
unknown_tags := chatTabs[chatJidStr].Messages[i].Raw.Unknown
|
||||
for _, v := range unknown_tags {
|
||||
if v.XMLName.Local == "occupant-id" {
|
||||
for _, attr := range v.Attrs {
|
||||
if attr.Name.Local == "id" {
|
||||
reason, ok := OccupantIdsToBlock[attr.Value]
|
||||
if ok {
|
||||
author.SetText("Ignored user")
|
||||
content.SetText("This user is ignored due to: " + reason)
|
||||
return // message is from blocked user
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
btn := vbox.Objects[3].(*widget.Button)
|
||||
reactions := vbox.Objects[4].(*fyne.Container)
|
||||
reactions = container.NewVBox()
|
||||
@@ -838,6 +856,9 @@ func main() {
|
||||
text = fmt.Sprintf("%s %s", text, jid.MustParse(name).Resourcepart())
|
||||
}
|
||||
|
||||
a := pubsub.Fetch(context.TODO(), client.Session, pubsub.Query{})
|
||||
log.Println(a.Item())
|
||||
|
||||
err = client.SendText(jid.MustParse(activeMucJid).Bare(), text)
|
||||
if err != nil {
|
||||
dialog.ShowError(err, w)
|
||||
@@ -1403,6 +1424,48 @@ func main() {
|
||||
dialog.ShowCustom("Message", "Close", pre, w)
|
||||
})
|
||||
|
||||
blck := fyne.NewMenuItem("ignore messages from this user", func() {
|
||||
|
||||
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
var activeChatJid string
|
||||
for jid, tabData := range UITabs {
|
||||
if tabData.Scroller == selectedScroller {
|
||||
activeChatJid = jid
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
m := chatTabs[activeChatJid].Messages[selectedId]
|
||||
unknown_tags := m.Raw.Unknown
|
||||
for _, v := range unknown_tags {
|
||||
if v.XMLName.Local == "occupant-id" {
|
||||
for _, attr := range v.Attrs {
|
||||
if attr.Name.Local == "id" {
|
||||
occupant_id := attr.Value
|
||||
reason, ok := OccupantIdsToBlock[occupant_id]
|
||||
if !ok {
|
||||
dialog.ShowConfirm("ignore user", "All messages sent by users with an occupant ID of\n"+occupant_id+"\nwill be ignored. Continue?", func(b bool) {
|
||||
if b {
|
||||
OccupantIdsToBlock[occupant_id] = "User requested"
|
||||
}
|
||||
}, w)
|
||||
} else {
|
||||
dialog.ShowConfirm("unignore user", "This user is currently ignored due to:\n"+reason+"\nWould you like to unignore them?", func(b bool) {
|
||||
if b {
|
||||
delete(OccupantIdsToBlock, occupant_id)
|
||||
}
|
||||
}, w)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
red := fyne.NewMenuItem("show read receipts on message", func() {
|
||||
pre := container.NewVBox()
|
||||
|
||||
@@ -1439,7 +1502,7 @@ func main() {
|
||||
dialog.ShowCustom("Message", "Close", pre, w)
|
||||
})
|
||||
|
||||
menu_messageoptions := fyne.NewMenu("Γ", bit, bia, bic, red)
|
||||
menu_messageoptions := fyne.NewMenu("Γ", bit, bia, bic, red, blck)
|
||||
ma := fyne.NewMainMenu(menu_help, menu_changeroom, menu_configureview, menu_messageoptions, menu_jokes)
|
||||
w.SetMainMenu(ma)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user