Merge branch 'master' into cross-signing

This commit is contained in:
Tulir Asokan 2020-11-12 00:21:11 +02:00
commit 661a7cf17a
17 changed files with 185 additions and 160 deletions

View File

@ -1,5 +1,5 @@
Package: gomuks
Version: 0.1.1-1
Version: 0.2.1-1
Section: net
Priority: optional
Architecture: amd64

15
go.mod
View File

@ -3,27 +3,26 @@ module maunium.net/go/gomuks
go 1.14
require (
github.com/alecthomas/chroma v0.8.0
github.com/alecthomas/chroma v0.8.1
github.com/disintegration/imaging v1.6.2
github.com/gabriel-vasile/mimetype v1.1.1
github.com/kyokomi/emoji v2.2.2+incompatible
github.com/lithammer/fuzzysearch v1.1.0
github.com/kyokomi/emoji/v2 v2.2.5
github.com/lithammer/fuzzysearch v1.1.1
github.com/lucasb-eyer/go-colorful v1.0.3
github.com/mattn/go-runewidth v0.0.9
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1
github.com/rivo/uniseg v0.1.0
github.com/russross/blackfriday/v2 v2.0.1
github.com/sasha-s/go-deadlock v0.2.0
github.com/zyedidia/clipboard v0.0.0-20200421031010-7c45b8673834
go.etcd.io/bbolt v1.3.4
golang.org/x/image v0.0.0-20200430140353-33d19683fad8
github.com/zyedidia/clipboard v1.0.3
go.etcd.io/bbolt v1.3.5
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5
golang.org/x/net v0.0.0-20201026091529-146b70c837a4
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2
gopkg.in/vansante/go-ffprobe.v2 v2.0.2
gopkg.in/yaml.v2 v2.3.0
maunium.net/go/mautrix v0.8.0-rc.2
maunium.net/go/mauview v0.1.1
maunium.net/go/mauview v0.1.2
maunium.net/go/tcell v0.2.0
)

43
go.sum
View File

@ -1,8 +1,8 @@
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
github.com/alecthomas/chroma v0.8.0 h1:HS+HE97sgcqjQGu5uVr8jIE55Mmh5UeQ7kckAhHg2pY=
github.com/alecthomas/chroma v0.8.0/go.mod h1:sko8vR34/90zvl5QdcUdvzL3J8NKjAUx9va9jPuFNoM=
github.com/alecthomas/chroma v0.8.1 h1:ym20sbvyC6RXz45u4qDglcgr8E313oPROshcuCHqiEE=
github.com/alecthomas/chroma v0.8.1/go.mod h1:sko8vR34/90zvl5QdcUdvzL3J8NKjAUx9va9jPuFNoM=
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
@ -37,12 +37,12 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/kyokomi/emoji v2.2.2+incompatible h1:gaQFbK2+uSxOR4iGZprJAbpmtqTrHhSdgOyIMD6Oidc=
github.com/kyokomi/emoji v2.2.2+incompatible/go.mod h1:mZ6aGCD7yk8j6QY6KICwnZ2pxoszVseX1DNoGtU2tBA=
github.com/kyokomi/emoji/v2 v2.2.5 h1:sxOmQKMB3ICTDWiJbtMHUnKn1HFHjGk9av0+IYWVovI=
github.com/kyokomi/emoji/v2 v2.2.5/go.mod h1:JUcn42DTdsXJo1SWanHh4HKDEyPaR5CqkmoirZZP9qE=
github.com/lib/pq v1.7.0 h1:h93mCPfUSkaul3Ka/VG8uZdmW1uMHDGxzu0NWHuJmHY=
github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lithammer/fuzzysearch v1.1.0 h1:go9v8tLCrNTTlH42OAaq4eHFe81TDHEnlrMEb6R4f+A=
github.com/lithammer/fuzzysearch v1.1.0/go.mod h1:Bqx4wo8lTOFcJr3ckpY6HA9lEIOO0H5HrkJ5CsN56HQ=
github.com/lithammer/fuzzysearch v1.1.1 h1:8F9OAV2xPuYblToVohjanztdnPjbtA0MLgMvDKQ0Z08=
github.com/lithammer/fuzzysearch v1.1.1/go.mod h1:H2bng+w5gsR7NlfIJM8ElGZI0sX6C/9uzGqicVXGU6c=
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
@ -50,14 +50,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/nikofil/mautrix-go v0.5.2-0.20200911223256-b40ab761fadc h1:Un166sriSTE07vajPm+iv+oHmBIH3b4PW2LO1fhRyKc=
github.com/nikofil/mautrix-go v0.5.2-0.20200911223256-b40ab761fadc/go.mod h1:xd0D0ekVts/UDBbjeDSs4wGlBfcarJDg0MMhVgHbxhs=
github.com/nikofil/mautrix-go v0.5.2-0.20200911232449-6010305aed05 h1:WFyJHdXasAvpno0OSvKgfmZHlq0WoyK+254vxmz4Mag=
github.com/nikofil/mautrix-go v0.5.2-0.20200911232449-6010305aed05/go.mod h1:xd0D0ekVts/UDBbjeDSs4wGlBfcarJDg0MMhVgHbxhs=
github.com/nikofil/mautrix-go v0.5.2-0.20200911234625-a585557b3750 h1:3eUgrAhYHnI0HidL2uO1uga8dpnqpAXIN0DB7uWc95Y=
github.com/nikofil/mautrix-go v0.5.2-0.20200911234625-a585557b3750/go.mod h1:xd0D0ekVts/UDBbjeDSs4wGlBfcarJDg0MMhVgHbxhs=
github.com/nikofil/mautrix-go v0.5.2-0.20200912211003-156aad4c3f86 h1:cVz8JHJyGRwve5EPDN7X6pUsP3/6Dy2c7gj7RCkZa50=
github.com/nikofil/mautrix-go v0.5.2-0.20200912211003-156aad4c3f86/go.mod h1:xd0D0ekVts/UDBbjeDSs4wGlBfcarJDg0MMhVgHbxhs=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@ -65,7 +57,6 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
@ -90,29 +81,27 @@ github.com/tidwall/pretty v1.0.1 h1:WE4RBSZ1x6McVVC8S/Md+Qse8YUv6HRObAx6ke00NY8=
github.com/tidwall/pretty v1.0.1/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/sjson v1.1.1 h1:7h1vk049Jnd5EH9NyzNiEuwYW4b5qgreBbqRC19AS3U=
github.com/tidwall/sjson v1.1.1/go.mod h1:yvVuSnpEQv5cYIrO+AT6kw4QVfd5SDZoGIS7/5+fZFs=
github.com/zyedidia/clipboard v0.0.0-20200421031010-7c45b8673834 h1:0nOfq3JwYRiY3+nwfWVQYEaXDmGCQgj3RKoqTifLzP4=
github.com/zyedidia/clipboard v0.0.0-20200421031010-7c45b8673834/go.mod h1:zykFnZUXX0ErxqvYLUFEq7QDJKId8rmh2FgD0/Y8cjA=
github.com/zyedidia/clipboard v1.0.3 h1:F/nCDVYMdbDWTmY8s8cJl0tnwX32q96IF09JHM14bUI=
github.com/zyedidia/clipboard v1.0.3/go.mod h1:zykFnZUXX0ErxqvYLUFEq7QDJKId8rmh2FgD0/Y8cjA=
github.com/zyedidia/poller v1.0.1/go.mod h1:vZXJOHGDcuK08GXhF6IAY0ZFd2WcgOR5DOTp84Uk5eE=
go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg=
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E=
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 h1:QelT11PB4FXiDEXucrfNckHoFxwt8USGY1ajP1ZF5lM=
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201022231255-08b38378de70/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201026091529-146b70c837a4 h1:awiuzyrRjJDb+OXi9ceHO3SDxVoN3JER57mhtqkdQBs=
golang.org/x/net v0.0.0-20201026091529-146b70c837a4/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -124,12 +113,10 @@ golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 h1:5B6i6EAiSYyejWfvc5Rc9BbI3rzIsrrXfAQBWnYfn+w=
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@ -147,7 +134,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
maunium.net/go/maulogger/v2 v2.1.1/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
maunium.net/go/mautrix v0.8.0-rc.2 h1:H1OieKdfTr4+i3lGgvydl+3z21CM4XgHzTrW8ozmsb8=
maunium.net/go/mautrix v0.8.0-rc.2/go.mod h1:TtVePxoEaw6+RZDKVajw66Yaj1lqLjH8l4FF3krsqWY=
maunium.net/go/mauview v0.1.1 h1:wfTXyPx3LGAGpTskh+UbBv/QItUWnEpaneHmywoYnfY=
maunium.net/go/mauview v0.1.1/go.mod h1:3QBUiuLct9moP1LgDhCGIg0Ovxn38Bd2sGndnUOuj4o=
maunium.net/go/mauview v0.1.2 h1:6Y3GpyckIlzCNkry6k025YhWg8oh5XJFj3RAMf4VwWo=
maunium.net/go/mauview v0.1.2/go.mod h1:3QBUiuLct9moP1LgDhCGIg0Ovxn38Bd2sGndnUOuj4o=
maunium.net/go/tcell v0.2.0 h1:1Q0kN3wCOGAIGu1r3QHADsjSUOPDylKREvCv3EzJpVg=
maunium.net/go/tcell v0.2.0/go.mod h1:9Apcb3lNNS6C6lCqKT9UFp7BTRzHXfWE+/tgufsAMho=

View File

@ -56,7 +56,7 @@ func NewGomuks(uiProvider ifc.UIProvider, configDir, dataDir, cacheDir, download
}
func (gmx *Gomuks) Version() string {
return "v0.2.0"
return "v0.2.1"
}
// Save saves the active session and message history.

View File

@ -1,5 +1,3 @@
// +build !windows,!darwin
// gomuks - A terminal Matrix client written in Go.
// Copyright (C) 2020 Tulir Asokan
//
@ -20,8 +18,22 @@ package open
import (
"os/exec"
"maunium.net/go/gomuks/debug"
)
func Open(input string) error {
return exec.Command("xdg-open", input).Start()
cmd := exec.Command(Command, append(Args, input)...)
err := cmd.Start()
if err != nil {
debug.Printf("Failed to start %s: %v", Command, err)
} else {
go func() {
waitErr := cmd.Wait()
if waitErr != nil {
debug.Printf("Failed to run %s: %v", Command, err)
}
}()
}
return err
}

View File

@ -1,25 +1,4 @@
// gomuks - A terminal Matrix client written in Go.
// Copyright (C) 2020 Tulir Asokan
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package open
import (
"os/exec"
)
func Open(input string) error {
return exec.Command("open", input).Start()
}
const Command = "open"
var Args []string

View File

@ -18,14 +18,10 @@ package open
import (
"os"
"os/exec"
"path/filepath"
)
const FileProtocolHandler = "url.dll,FileProtocolHandler"
var RunDLL32 = filepath.Join(os.Getenv("SYSTEMROOT"), "System32", "rundll32.exe")
func Open(input string) error {
return exec.Command(RunDLL32, FileProtocolHandler, input).Start()
}
var Command = filepath.Join(os.Getenv("SYSTEMROOT"), "System32", "rundll32.exe")
var Args = []string{FileProtocolHandler}

6
lib/open/open_xdg.go Normal file
View File

@ -0,0 +1,6 @@
// +build !windows,!darwin
package open
const Command = "xdg-open"
var Args []string

View File

@ -19,10 +19,9 @@
package matrix
import (
"fmt"
"path/filepath"
"github.com/pkg/errors"
"maunium.net/go/mautrix/crypto"
"maunium.net/go/gomuks/debug"
@ -53,14 +52,14 @@ func isBadEncryptError(err error) bool {
func (c *Container) initCrypto() error {
cryptoStore, err := crypto.NewGobStore(filepath.Join(c.config.DataDir, "crypto.gob"))
if err != nil {
return errors.Wrap(err, "failed to open crypto store")
return fmt.Errorf("failed to open crypto store: %w", err)
}
crypt := crypto.NewOlmMachine(c.client, cryptoLogger{}, cryptoStore, c.config.Rooms)
crypt.AllowUnverifiedDevices = !c.config.SendToVerifiedOnly
c.crypto = crypt
err = c.crypto.Load()
if err != nil {
return errors.Wrap(err, "failed to create olm machine")
return fmt.Errorf("failed to create olm machine: %w", err)
}
return nil
}

View File

@ -32,8 +32,7 @@ import (
"runtime"
dbg "runtime/debug"
"time"
"github.com/pkg/errors"
"errors"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/crypto/attachment"
@ -115,7 +114,7 @@ func (c *Container) InitClient() error {
var err error
c.client, err = mautrix.NewClient(c.config.HS, mxid, accessToken)
if err != nil {
return errors.Wrap(err, "failed to create mautrix client")
return fmt.Errorf("failed to create mautrix client: %w", err)
}
c.client.UserAgent = fmt.Sprintf("gomuks %s (with mautrix-go %s)", c.gmx.Version(), mautrix.Version)
c.client.Logger = mxLogger{}
@ -123,13 +122,13 @@ func (c *Container) InitClient() error {
err = c.initCrypto()
if err != nil {
return errors.Wrap(err, "failed to initialize crypto")
return fmt.Errorf("failed to initialize crypto: %w", err)
}
if c.history == nil {
c.history, err = NewHistoryManager(c.config.HistoryPath)
if err != nil {
return errors.Wrap(err, "failed to initialize history")
return fmt.Errorf("failed to initialize history: %w", err)
}
}
@ -252,13 +251,14 @@ func (c *Container) Login(user, password string) error {
if err != nil {
return err
}
if len(resp.Flows) == 1 && resp.Flows[0].Type == "m.login.password" {
return c.PasswordLogin(user, password)
} else if len(resp.Flows) == 2 && resp.Flows[0].Type == "m.login.sso" && resp.Flows[1].Type == "m.login.token" {
return c.SingleSignOn()
} else {
return fmt.Errorf("no supported login flows")
for _, flow := range resp.Flows {
if flow.Type == "m.login.password" {
return c.PasswordLogin(user, password)
} else if flow.Type == "m.login.sso" {
return c.SingleSignOn()
}
}
return fmt.Errorf("no supported login flows")
}
// Logout revokes the access token, stops the syncer and calls the OnLogout() method of the UI.
@ -430,7 +430,8 @@ func (c *Container) Start() {
default:
if err := c.client.Sync(); err != nil {
if errors.Is(err, mautrix.MUnknownToken) {
debug.Print("Sync() errored with", err, "-> logging out")
debug.Print("Sync() errored with ", err, " -> logging out")
// TODO support soft logout
c.Logout()
} else {
debug.Print("Sync() errored", err)
@ -953,7 +954,7 @@ func (c *Container) UploadMedia(path string, encrypt bool) (*ifc.UploadedMediaIn
var err error
path, err = filepath.Abs(path)
if err != nil {
return nil, errors.Wrap(err, "failed to get absolute path")
return nil, fmt.Errorf("failed to get absolute path: %w", err)
}
msgtype, info, err := getMediaInfo(path)
@ -963,12 +964,12 @@ func (c *Container) UploadMedia(path string, encrypt bool) (*ifc.UploadedMediaIn
file, err := os.Open(path)
if err != nil {
return nil, errors.Wrap(err, "failed to open file")
return nil, fmt.Errorf("failed to open file: %w", err)
}
stat, err := file.Stat()
if err != nil {
return nil, errors.Wrap(err, "failed to get file info")
return nil, fmt.Errorf("failed to get file info: %w", err)
}
uploadFileName := stat.Name()

View File

@ -25,22 +25,22 @@ import (
"time"
"github.com/gabriel-vasile/mimetype"
"github.com/pkg/errors"
"gopkg.in/vansante/go-ffprobe.v2"
"maunium.net/go/gomuks/debug"
"maunium.net/go/mautrix/event"
"maunium.net/go/gomuks/debug"
)
func getImageInfo(path string) (event.FileInfo, error) {
var info event.FileInfo
file, err := os.Open(path)
if err != nil {
return info, errors.Wrap(err, "failed to open image to get info")
return info, fmt.Errorf("failed to open image to get info: %w", err)
}
cfg, _, err := image.DecodeConfig(file)
if err != nil {
return info, errors.Wrap(err, "failed to get image info")
return info, fmt.Errorf("failed to get image info: %w", err)
}
info.Width = cfg.Width
info.Height = cfg.Height
@ -53,7 +53,7 @@ func getFFProbeInfo(mimeClass, path string) (msgtype event.MessageType, info eve
var probedInfo *ffprobe.ProbeData
probedInfo, err = ffprobe.ProbeURL(ctx, path)
if err != nil {
err = errors.Wrap(err, fmt.Sprintf("failed to get %s info with ffprobe", mimeClass))
err = fmt.Errorf("failed to get %s info with ffprobe: %w", mimeClass, err)
return
}
if mimeClass == "audio" {
@ -78,7 +78,7 @@ func getMediaInfo(path string) (msgtype event.MessageType, info event.FileInfo,
var mime *mimetype.MIME
mime, err = mimetype.DetectFile(path)
if err != nil {
err = errors.Wrap(err, "failed to get content type")
err = fmt.Errorf("failed to get content type: %w", err)
return
}

View File

@ -19,16 +19,17 @@ package rooms
import (
"compress/gzip"
"encoding/gob"
"fmt"
"os"
"path/filepath"
"time"
"github.com/pkg/errors"
sync "github.com/sasha-s/go-deadlock"
"maunium.net/go/gomuks/debug"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/id"
"maunium.net/go/gomuks/debug"
)
// RoomCache contains room state info in a hashmap and linked list.
@ -114,14 +115,14 @@ func (cache *RoomCache) LoadList() error {
if os.IsNotExist(err) {
return nil
}
return errors.Wrap(err, "failed to open room list file for reading")
return fmt.Errorf("failed to open room list file for reading: %w", err)
}
defer debugPrintError(file.Close, "Failed to close room list file after reading")
// Open gzip reader for room list file
cmpReader, err := gzip.NewReader(file)
if err != nil {
return errors.Wrap(err, "failed to read gzip room list")
return fmt.Errorf("failed to read gzip room list: %w", err)
}
defer debugPrintError(cmpReader.Close, "Failed to close room list gzip reader")
@ -131,7 +132,7 @@ func (cache *RoomCache) LoadList() error {
var size int
err = dec.Decode(&size)
if err != nil {
return errors.Wrap(err, "failed to read size of room list")
return fmt.Errorf("failed to read size of room list: %w", err)
}
// Read list
@ -167,7 +168,7 @@ func (cache *RoomCache) SaveList() error {
// Open room list file
file, err := os.OpenFile(cache.listPath, os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
return errors.Wrap(err, "failed to open room list file for writing")
return fmt.Errorf("failed to open room list file for writing: %w", err)
}
defer debugPrintError(file.Close, "Failed to close room list file after writing")
@ -180,7 +181,7 @@ func (cache *RoomCache) SaveList() error {
// Write number of items in list
err = enc.Encode(len(cache.Map))
if err != nil {
return errors.Wrap(err, "failed to write size of room list")
return fmt.Errorf("failed to write size of room list: %w", err)
}
// Write list

View File

@ -18,6 +18,7 @@ package ui
import (
"encoding/json"
"errors"
"fmt"
"io"
"math"
@ -34,7 +35,6 @@ import (
"unicode"
"github.com/lucasb-eyer/go-colorful"
"github.com/pkg/errors"
"github.com/russross/blackfriday/v2"
"maunium.net/go/mautrix"
@ -225,7 +225,7 @@ func readRoomAlias(cmd *Command) (alias id.RoomAlias, err error) {
param := strings.Join(cmd.Args[1:], " ")
if strings.ContainsRune(param, ':') {
if param[0] != '#' {
return "", errors.New("Full aliases must start with #")
return "", errors.New("full aliases must start with #")
}
alias = id.RoomAlias(param)
@ -454,60 +454,8 @@ func cmdUnknownCommand(cmd *Command) {
}
func cmdHelp(cmd *Command) {
cmd.Reply(`# General
/help - Show this "temporary" help message.
/quit - Quit gomuks.
/clearcache - Clear cache and quit gomuks.
/logout - Log out of Matrix.
/toggle <thing> - Temporary command to toggle various UI features.
Things: rooms, users, baremessages, images, typingnotif, unverified
# Sending special messages
/me <message> - Send an emote message.
/notice <message> - Send a notice (generally used for bot messages).
/rainbow <message> - Send rainbow text (markdown not supported).
/rainbowme <message> - Send rainbow text in an emote.
/reply [text] - Reply to the selected message.
/react <reaction> - React to the selected message.
/redact [reason] - Redact the selected message.
/edit - Edit the selected message.
# Encryption
/fingerprint - View the fingerprint of your device.
/devices <user id> - View the device list of a user.
/device <user id> <device id> - Show info about a specific device.
/unverify <user id> <device id> - Un-verify a device.
/blacklist <user id> <device id> - Blacklist a device.
/verify <user id> <device id> [fingerprint]
- Verify a device. If the fingerprint is not provided,
interactive emoji verification will be started.
/reset-session - Reset the outbound Megolm session in the current room.
/import <file> - Import encryption keys
/export <file> - Export encryption keys
/export-room <file> - Export encryption keys for the current room.
# Rooms
/pm <user id> <...> - Create a private chat with the given user(s).
/create [room name] - Create a room.
/join <room> [server] - Join a room.
/accept - Accept the invite.
/reject - Reject the invite.
/invite <user id> - Invite the given user to the room.
/roomnick <name> - Change your per-room displayname.
/tag <tag> <priority> - Add the room to <tag>.
/untag <tag> - Remove the room from <tag>.
/tags - List the tags the room is in.
/alias <act> <name> - Add or remove local addresses.
/leave - Leave the current room.
/kick <user id> [reason] - Kick a user.
/ban <user id> [reason] - Ban a user.
/unban <user id> - Unban a user.`)
view := cmd.MainView
view.ShowModal(NewHelpModal(view))
}
func cmdLeave(cmd *Command) {

95
ui/help-modal.go Normal file
View File

@ -0,0 +1,95 @@
package ui
import (
"maunium.net/go/tcell"
"maunium.net/go/mauview"
)
const helpText = `# General
/help - Show this help dialog.
/quit - Quit gomuks.
/clearcache - Clear cache and quit gomuks.
/logout - Log out of Matrix.
/toggle <thing> - Temporary command to toggle various UI features.
# Sending special messages
/me <message> - Send an emote message.
/notice <message> - Send a notice (generally used for bot messages).
/rainbow <message> - Send rainbow text.
/rainbowme <message> - Send rainbow text in an emote.
/reply [text] - Reply to the selected message.
/react <reaction> - React to the selected message.
/redact [reason] - Redact the selected message.
/edit - Edit the selected message.
# Encryption
/fingerprint - View the fingerprint of your device.
/devices <user id> - View the device list of a user.
/device <user id> <device id> - Show info about a specific device.
/unverify <user id> <device id> - Un-verify a device.
/blacklist <user id> <device id> - Blacklist a device.
/verify <user id> <device id> [fingerprint]
- Verify a device. If the fingerprint is not provided,
interactive emoji verification will be started.
/reset-session - Reset the outbound Megolm session in the current room.
/import <file> - Import encryption keys
/export <file> - Export encryption keys
/export-room <file> - Export encryption keys for the current room.
# Rooms
/pm <user id> <...> - Create a private chat with the given user(s).
/create [room name] - Create a room.
/join <room> [server] - Join a room.
/accept - Accept the invite.
/reject - Reject the invite.
/invite <user id> - Invite the given user to the room.
/roomnick <name> - Change your per-room displayname.
/tag <tag> <priority> - Add the room to <tag>.
/untag <tag> - Remove the room from <tag>.
/tags - List the tags the room is in.
/alias <act> <name> - Add or remove local addresses.
/leave - Leave the current room.
/kick <user id> [reason] - Kick a user.
/ban <user id> [reason] - Ban a user.
/unban <user id> - Unban a user.`
type HelpModal struct {
mauview.FocusableComponent
parent *MainView
}
func NewHelpModal(parent *MainView) *HelpModal {
hm := &HelpModal{parent: parent}
text := mauview.NewTextView().
SetText(helpText).
SetScrollable(true).
SetWrap(false)
box := mauview.NewBox(text).
SetBorder(true).
SetTitle("Help").
SetBlurCaptureFunc(func() bool {
hm.parent.HideModal()
return true
})
box.Focus()
hm.FocusableComponent = mauview.FractionalCenter(box, 42, 10, 0.5, 0.5)
return hm
}
func (hm *HelpModal) OnKeyEvent(event mauview.KeyEvent) bool {
if event.Key() == tcell.KeyEscape || event.Rune() == 'q' {
hm.parent.HideModal()
return true
}
return hm.FocusableComponent.OnKeyEvent(event)
}

View File

@ -360,6 +360,7 @@ func (view *MessageView) SetSelected(message *messages.UIMessage) {
func (view *MessageView) handleMessageClick(message *messages.UIMessage, mod tcell.ModMask) bool {
if msg, ok := message.Renderer.(*messages.FileMessage); ok && mod > 0 && !msg.Thumbnail.IsEmpty() {
debug.Print("Opening thumbnail", msg.ThumbnailPath())
open.Open(msg.ThumbnailPath())
// No need to re-render
return false

View File

@ -320,7 +320,7 @@ func (parser *htmlParser) syntaxHighlight(text, language string) Entity {
func (parser *htmlParser) codeblockToEntity(node *html.Node) Entity {
lang := "plaintext"
// TODO allow disabling syntax highlighting
if node.FirstChild.Type == html.ElementNode && node.FirstChild.Data == "code" {
if node.FirstChild != nil && node.FirstChild.Type == html.ElementNode && node.FirstChild.Data == "code" {
node = node.FirstChild
attr := parser.getAttribute(node, "class")
for _, class := range strings.Split(attr, " ") {

View File

@ -24,7 +24,7 @@ import (
"time"
"unicode"
"github.com/kyokomi/emoji"
"github.com/kyokomi/emoji/v2"
"github.com/mattn/go-runewidth"
"github.com/zyedidia/clipboard"
@ -713,6 +713,7 @@ func (view *RoomView) Download(url id.ContentURI, file *attachment.EncryptedFile
view.AddServiceMessage(fmt.Sprintf("File downloaded to %s", path))
view.parent.parent.Render()
if openFile {
debug.Print("Opening file", path)
open.Open(path)
}
}