Skip to content
This repository was archived by the owner on Nov 25, 2024. It is now read-only.

Conversation

Cnly
Copy link
Contributor

@Cnly Cnly commented Jun 18, 2019

This PR adds a new consumer for typing notifications in syncapi. It also brings changes to syncserver.go and some related files so EDUs can better fit in /sync responses.

Fixes #635.
Fixes #574.

Signed-off-by: Alex Chen minecnly@gmail.com

Pull Request Checklist

  • I have added any new tests that need to pass to testfile as specified in docs/sytest.md
  • Pull request includes a sign off

Signed-off-by: Alex Chen <minecnly@gmail.com>
@Cnly Cnly force-pushed the syncapi-typing-notifications-635 branch from f056bec to b896fdc Compare June 25, 2019 08:01
@anoadragon453
Copy link
Member

anoadragon453 commented Jun 25, 2019

Could you fix the linting? Cyclomatic complexity just means the function has too many branching statements (it is indeed annoying but helps keep functions to a reasonable number of lines).

Also during testing I received a stack trace whenever sending a typing event:

INFO[2019-06-25T13:31:27.257914853Z] Incoming request                              req.id=hsiy5pdFCqqy req.method=PUT req.path="/_matrix/client/r0/rooms/!aaLEoOz66BAshy1K:localhost/typing/@bla:localhost"
ERRO[2019-06-25T13:31:27.258729695Z] Request panicked!
goroutine 130 [running]:
runtime/debug.Stack(0xc000392cc0, 0xc0002192b8, 0xc000392d20)
	/usr/lib/go-1.11/src/runtime/debug/stack.go:24 +0xa7
github.com/matrix-org/util.Protect.func1.1(0xc0005c2700, 0xc05ec0, 0xc000652c40)
	/home/user/go/pkg/mod/github.com/matrix-org/util@v0.0.0-20171127121716-2e2df66af2f5/json.go:87 +0x16f
panic(0xa6a140, 0x1070190)
	/usr/lib/go-1.11/src/runtime/panic.go:513 +0x1b9
github.com/matrix-org/dendrite/typingserver/cache.(*TypingCache).GetTypingUsersIfUpdatedAfter(0xc000251b30, 0xc00001cab9, 0x1b, 0x0, 0x8, 0xc0002196c0, 0xc000219698, 0x8)
	/home/user/code/dendrite/typingserver/cache/cache.go:66 +0x8a
github.com/matrix-org/dendrite/typingserver/cache.(*TypingCache).GetTypingUsers(0xc000251b30, 0xc00001cab9, 0x1b, 0xc000032000, 0x203000, 0x203000)
	/home/user/code/dendrite/typingserver/cache/cache.go:53 +0x48
github.com/matrix-org/dendrite/typingserver/input.(*TypingServerInputAPI).sendEvent(0xc000251b60, 0xc000280a80, 0xe, 0xc00001cab9)
	/home/user/code/dendrite/typingserver/input/input.go:60 +0x5d
github.com/matrix-org/dendrite/typingserver/input.(*TypingServerInputAPI).InputTypingEvent(0xc000251b60, 0xc06b00, 0xc00044b6b0, 0xc000280a80, 0x109bae8, 0xa03020, 0xc00018c9f0)
	/home/user/code/dendrite/typingserver/input/input.go:56 +0xff
github.com/matrix-org/dendrite/clientapi/producers.(*TypingServerProducer).Send(0xc0002824a0, 0xc06b00, 0xc00044b6b0, 0xc00001cadc, 0xe, 0xc00001cab9, 0x1b, 0xc00001ca00, 0x0, 0xc00001cab9, ...)
	/home/user/code/dendrite/clientapi/producers/typingserver.go:49 +0x1bb
github.com/matrix-org/dendrite/clientapi/routing.SendTyping(0xc0005c2800, 0xc00044b770, 0xc00001cab9, 0x1b, 0xc00001cadc, 0xe, 0xc0001fe0f0, 0xc0002824a0, 0xb36e12, 0x6, ...)
	/home/user/code/dendrite/clientapi/routing/sendtyping.go:70 +0x2bb
github.com/matrix-org/dendrite/clientapi/routing.Setup.func17(0xc0005c2800, 0xc00044b770, 0xc0001fe0f0, 0xbff7e0, 0xc00019a960, 0x0)
	/home/user/code/dendrite/clientapi/routing/routing.go:187 +0x128
github.com/matrix-org/dendrite/common.MakeAuthAPI.func1(0xc0005c2800, 0x0, 0x0, 0x0, 0x0)
	/home/user/code/dendrite/common/httpapi.go:27 +0xb6
github.com/matrix-org/util.(*jsonRequestHandlerWrapper).OnIncomingRequest(0xc000196518, 0xc0005c2800, 0xc00012f680, 0x80, 0x80, 0xb05c20)
	/home/user/go/pkg/mod/github.com/matrix-org/util@v0.0.0-20171127121716-2e2df66af2f5/json.go:68 +0x33
github.com/matrix-org/util.MakeJSONAPI.func1(0xc05ec0, 0xc000652c40, 0xc0005c2800)
	/home/user/go/pkg/mod/github.com/matrix-org/util@v0.0.0-20171127121716-2e2df66af2f5/json.go:128 +0x89
github.com/matrix-org/util.Protect.func1(0xc05ec0, 0xc000652c40, 0xc0005c2700)
	/home/user/go/pkg/mod/github.com/matrix-org/util@v0.0.0-20171127121716-2e2df66af2f5/json.go:92 +0x8b
net/http.HandlerFunc.ServeHTTP(0xc000283350, 0xc05ec0, 0xc000652c40, 0xc0005c2700)
	/usr/lib/go-1.11/src/net/http/server.go:1964 +0x44
github.com/matrix-org/dendrite/common.MakeExternalAPI.func1(0xc05ec0, 0xc000652c40, 0xc0005c2600)
	/home/user/code/dendrite/common/httpapi.go:40 +0x190
net/http.HandlerFunc.ServeHTTP(0xc0002e6280, 0xc05ec0, 0xc000652c40, 0xc0005c2600)
	/usr/lib/go-1.11/src/net/http/server.go:1964 +0x44
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00019a780, 0xc05ec0, 0xc000652c40, 0xc0005c2600)
	/home/user/go/pkg/mod/github.com/gorilla/mux@v1.3.0/mux.go:114 +0xe0
github.com/matrix-org/dendrite/common.WrapHandlerInCORS.func1(0xc05ec0, 0xc000652c40, 0xc0005c2400)
	/home/user/code/dendrite/common/httpapi.go:114 +0x169
net/http.HandlerFunc.ServeHTTP(0xc0004a8700, 0xc05ec0, 0xc000652c40, 0xc0005c2400)
	/usr/lib/go-1.11/src/net/http/server.go:1964 +0x44
net/http.(*ServeMux).ServeHTTP(0x107dc40, 0xc05ec0, 0xc000652c40, 0xc0005c2400)
	/usr/lib/go-1.11/src/net/http/server.go:2361 +0x127
net/http.serverHandler.ServeHTTP(0xc0004b60d0, 0xc05ec0, 0xc000652c40, 0xc0005c2400)
	/usr/lib/go-1.11/src/net/http/server.go:2741 +0xab
net/http.(*conn).serve(0xc0000a6140, 0xc06a40, 0xc0001922c0)
	/usr/lib/go-1.11/src/net/http/server.go:1847 +0x646
created by net/http.(*Server).Serve
	/usr/lib/go-1.11/src/net/http/server.go:2851 +0x2f5  context=missing panic="runtime error: invalid memory address or nil pointer dereference"
INFO[2019-06-25T13:31:27.258879396Z] Responding (35 bytes)                         code=500 context=missing

Cnly added 3 commits June 25, 2019 22:22
Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
@Cnly
Copy link
Contributor Author

Cnly commented Jun 25, 2019

Linting, complexity and nil pointer dereference should all be fixed now.

Cnly added 14 commits June 26, 2019 17:45
Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
…r and notifier

Signed-off-by: Alex Chen <minecnly@gmail.com>
…ypingEvent

Signed-off-by: Alex Chen <minecnly@gmail.com>
Previously, currPos, obtained using notifier.CurrentPosition(), is passed
to GetNotifyChannel. Since this is already the latest position on the
server, the client won't get updates until (1) a even newer event arrives at
the server, or (2) the /sync request times out.

(2) above is possible because when it times out, notifier calculates
currentSyncForUser based on syncReq, which contains the correct since pos
token that the client sent the server.

Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
…elta")

Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
@anoadragon453 anoadragon453 requested a review from a team June 27, 2019 17:20
@anoadragon453 anoadragon453 self-assigned this Jun 27, 2019
Signed-off-by: Alex Chen <minecnly@gmail.com>
@Cnly
Copy link
Contributor Author

Cnly commented Jun 27, 2019

Just refined some docs. The PR is now ready for review! :)

Cnly added 2 commits July 1, 2019 19:38
Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
@anoadragon453
Copy link
Member

Also, please merge master into this branch.

(The fact testfile is so easy to conflict on makes me a little worried).

Signed-off-by: Alex Chen <minecnly@gmail.com>
Signed-off-by: Alex Chen <minecnly@gmail.com>
@Cnly Cnly requested a review from anoadragon453 July 12, 2019 12:52
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! other than just some small grammatical things

Cnly and others added 2 commits July 12, 2019 22:26
Co-Authored-By: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
Co-Authored-By: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
@Cnly Cnly merged commit 29841be into matrix-org:master Jul 12, 2019
Cnly added a commit to Cnly/dendrite that referenced this pull request Jul 19, 2019
In 29841be (matrix-org#718), EDUs are added to /sync responses for rooms listed
in joinedRoomIDs returned by addPDUDeltaToResponse. However this list
may contain rooms other than those currently joined.

Some variable renamings are done to make golangci-lint pass.

Signed-off-by: Alex Chen <minecnly@gmail.com>
anoadragon453 pushed a commit that referenced this pull request Jul 31, 2019
In 29841be (#718), EDUs are added to /sync responses for rooms listed
in joinedRoomIDs returned by addPDUDeltaToResponse. However this list
may contain rooms other than those currently joined.

Some variable renamings are done to make golangci-lint pass.

Signed-off-by: Alex Chen minecnly@gmail.com
Trion129 pushed a commit to Trion129/dendrite that referenced this pull request Jul 31, 2019
…org#752)

In 29841be (matrix-org#718), EDUs are added to /sync responses for rooms listed
in joinedRoomIDs returned by addPDUDeltaToResponse. However this list
may contain rooms other than those currently joined.

Some variable renamings are done to make golangci-lint pass.

Signed-off-by: Alex Chen minecnly@gmail.com
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the syncapi consume messages from the typing server’s topic [syncserver] Support typing events

2 participants