Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FromID same for both parties in one to one chat #288

Open
spacemolly opened this issue Apr 9, 2021 · 4 comments
Open

FromID same for both parties in one to one chat #288

spacemolly opened this issue Apr 9, 2021 · 4 comments
Labels
area: client telegram package issues bug Something isn't working

Comments

@spacemolly
Copy link

What version of gotd are you using?

$ go list -m github.com/gotd/td
github.com/gotd/td v0.33.3

Does this issue reproduce with the latest release?

Yes

What did you do?

Not 100% sure this is a bug but it's at least unexpected and inconsistent so leaning towards it being one. So sorry if i'm wrong!

I'm receiving message in a one to one chat via OnNewMessage dispatcher. When I send the first message the FromID is the user id of the first user (which is expected), but the response Message and all future messages from the other user, has the same FromID as the first user. So it looks like messages all come from the same user, the first one.

Here are two (abbreviated) json-encoded messages:

First:

{
 "Flags": 0,
 "Out": false,
 "Mentioned": false,
 "MediaUnread": false,
 "Silent": false,
 "Post": false,
 "FromScheduled": false,
 "Legacy": false,
 "EditHide": false,
 "Pinned": false,
 "ID": 3402,
 "FromID": {
  "UserID": 56132410
 },
 "PeerID": {
  "UserID": 56132410
 },
 "Date": 1617977512,
 "Message": "Hello",
}

Second:

 {
 "Flags": 0,
 "Out": true,
 "Mentioned": false,
 "MediaUnread": false,
 "Silent": false,
 "Post": false,
 "FromScheduled": false,
 "Legacy": false,
 "EditHide": false,
 "Pinned": false,
 "ID": 3407,
 "FromID": {
  "UserID": 56132410
 },
 "PeerID": {
  "UserID": 56132410
 },
 "Date": 1618004712,
 "Message": "Hi again",
}

What did you expect to see?

I expected the FromID to be the user id of the user who actually sent the message.

What did you see instead?

As you see in the above examples, both the from user id and the peer user id is the same in both messages, the id of the user who initiated the chat.

What Go version and environment are you using?

$ go version
go version go1.16 darwin/amd64

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Library/Caches/go-build"
GOENV="/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/j1/hgqrbz2n1xsgz6_2c0slq9nh0000gn/T/go-build3091972184=/tmp/go-build -gno-record-gcc-switches -fno-common"

@spacemolly spacemolly added the bug Something isn't working label Apr 9, 2021
@shadowspore shadowspore added the area: client telegram package issues label Apr 10, 2021
@ernado
Copy link
Member

ernado commented Apr 11, 2021

Please try v0.34.0

@spacemolly
Copy link
Author

Tested with v0.34.0, now FromID is simply Nil. PeerID is the same as before and that probably makes sense.

Is there a way to access current client UserID and use this when Out is true?

 {
 "Flags": 0,
 "Out": true,
 "Mentioned": false,
 "MediaUnread": false,
 "Silent": false,
 "Post": false,
 "FromScheduled": false,
 "Legacy": false,
 "EditHide": false,
 "Pinned": false,
 "ID": 3408,
 "FromID": null,
 "PeerID": {
  "UserID": 56132410
 },
 "Date": 1618143621,
 "Message": "Testing"
}

@ernado
Copy link
Member

ernado commented Apr 11, 2021

For now you can use Client.Self method to access current UserID and cache it.

Initially @xjem proposed to do it implicitly (cache it on first call and set FromID), but currently there is no consensus in gotd development team.

@spacemolly
Copy link
Author

Thanks! Ok, that's an alright work around

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: client telegram package issues bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants