Add nickname fallback for rooms that don't have XEP-0421
This commit is contained in:
24
main.go
24
main.go
@@ -187,7 +187,7 @@ func main() {
|
||||
Jid: loadedConfig.Username + "/lambda." + str,
|
||||
Credential: xmpp.Password(loadedConfig.Password),
|
||||
Insecure: loadedConfig.Insecure,
|
||||
// StreamLogger: os.Stdout,
|
||||
StreamLogger: os.Stdout,
|
||||
}
|
||||
router := xmpp.NewRouter()
|
||||
|
||||
@@ -304,6 +304,10 @@ func main() {
|
||||
|
||||
if ok { // This is a presence stanza from a user in a MUC
|
||||
presence.Get(&ocu)
|
||||
id := ocu.ID
|
||||
if id == "" {
|
||||
id = JidMustParse(presence.From).Resource
|
||||
}
|
||||
from, _ := stanza.NewJid(presence.From)
|
||||
muc := from.Bare()
|
||||
_, ok = mucmembers.Load(muc)
|
||||
@@ -319,9 +323,9 @@ func main() {
|
||||
typed_unit := unit.(mucUnit)
|
||||
|
||||
if presence.Type != "unavailable" {
|
||||
typed_unit.Members.Store(ocu.ID, presence)
|
||||
typed_unit.Members.Store(id, presence)
|
||||
} else {
|
||||
typed_unit.Members.Delete(ocu.ID)
|
||||
typed_unit.Members.Delete(id)
|
||||
glib.IdleAdd(func() {
|
||||
b := gtk.NewLabel("")
|
||||
ba, ok := generatePresenceWidget(p).(*gtk.Label)
|
||||
@@ -431,6 +435,15 @@ func activate(app *gtk.Application) {
|
||||
fileMenu.Append("Join MUC", "app.join")
|
||||
fileMenu.Append("Start DM", "app.dm")
|
||||
|
||||
helpMenu := gio.NewMenu()
|
||||
helpMenu.Append("About", "app.about")
|
||||
|
||||
aboutAction := gio.NewSimpleAction("about", nil)
|
||||
aboutAction.ConnectActivate(func(p *glib.Variant) {
|
||||
a := gtk.AboutDialog{}
|
||||
a.SetVisible(true)
|
||||
})
|
||||
|
||||
joinAction := gio.NewSimpleAction("join", nil)
|
||||
joinAction.ConnectActivate(func(p *glib.Variant) {
|
||||
box := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
@@ -464,7 +477,7 @@ func activate(app *gtk.Application) {
|
||||
|
||||
win := gtk.NewWindow()
|
||||
win.SetTitle("Join MUC")
|
||||
win.SetDefaultSize(200, 200)
|
||||
win.SetDefaultSize(400, 1)
|
||||
win.SetChild(box)
|
||||
|
||||
btn.ConnectClicked(func() {
|
||||
@@ -492,8 +505,11 @@ func activate(app *gtk.Application) {
|
||||
})
|
||||
|
||||
app.AddAction(joinAction)
|
||||
app.AddAction(aboutAction)
|
||||
|
||||
the_menu.AppendSubmenu("File", fileMenu)
|
||||
the_menu.AppendSubmenu("Help", helpMenu)
|
||||
|
||||
|
||||
the_menuBar := gtk.NewPopoverMenuBarFromModel(the_menu)
|
||||
app.SetMenubar(gio.NewMenu())
|
||||
|
||||
Reference in New Issue
Block a user