Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
6dd50da5
Commit
6dd50da5
authored
10 years ago
by
Paul "LeoNerd" Evans
Browse files
Options
Downloads
Patches
Plain Diff
Define a new event stream data source for typing notifications (currently null)
parent
f85a3757
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
synapse/handlers/typing.py
+14
-0
14 additions, 0 deletions
synapse/handlers/typing.py
synapse/streams/events.py
+13
-7
13 additions, 7 deletions
synapse/streams/events.py
synapse/types.py
+1
-1
1 addition, 1 deletion
synapse/types.py
tests/rest/test_presence.py
+5
-3
5 additions, 3 deletions
tests/rest/test_presence.py
with
33 additions
and
11 deletions
synapse/handlers/typing.py
+
14
−
0
View file @
6dd50da5
...
...
@@ -145,3 +145,17 @@ class TypingNotificationHandler(BaseHandler):
typing
):
# TODO(paul) steal this from presence.py
pass
class
TypingNotificationEventSource
(
object
):
def
__init__
(
self
,
hs
):
self
.
hs
=
hs
def
get_new_events_for_user
(
self
,
user
,
from_token
,
limit
):
return
([],
0
)
def
get_current_token_part
(
self
):
return
0
def
get_pagination_rows
(
self
,
user
,
pagination_config
,
key
):
return
([],
0
)
This diff is collapsed.
Click to expand it.
synapse/streams/events.py
+
13
−
7
View file @
6dd50da5
...
...
@@ -19,6 +19,7 @@ from synapse.types import StreamToken
from
synapse.handlers.presence
import
PresenceEventSource
from
synapse.handlers.room
import
RoomEventSource
from
synapse.handlers.typing
import
TypingNotificationEventSource
class
NullSource
(
object
):
...
...
@@ -41,6 +42,7 @@ class EventSources(object):
SOURCE_TYPES
=
{
"
room
"
:
RoomEventSource
,
"
presence
"
:
PresenceEventSource
,
"
typing
"
:
TypingNotificationEventSource
,
}
def
__init__
(
self
,
hs
):
...
...
@@ -49,15 +51,19 @@ class EventSources(object):
for
name
,
cls
in
EventSources
.
SOURCE_TYPES
.
items
()
}
@staticmethod
def
create_token
(
events_key
,
presence_key
):
return
StreamToken
(
events_key
=
events_key
,
presence_key
=
presence_key
)
@defer.inlineCallbacks
def
get_current_token
(
self
):
events_key
=
yield
self
.
sources
[
"
room
"
].
get_current_token_part
()
presence_key
=
yield
self
.
sources
[
"
presence
"
].
get_current_token_part
()
token
=
EventSources
.
create_token
(
events_key
,
presence_key
)
token
=
StreamToken
(
events_key
=
(
yield
self
.
sources
[
"
room
"
].
get_current_token_part
()
),
presence_key
=
(
yield
self
.
sources
[
"
presence
"
].
get_current_token_part
()
),
typing_key
=
(
yield
self
.
sources
[
"
typing
"
].
get_current_token_part
()
)
)
defer
.
returnValue
(
token
)
...
...
This diff is collapsed.
Click to expand it.
synapse/types.py
+
1
−
1
View file @
6dd50da5
...
...
@@ -97,7 +97,7 @@ class RoomID(DomainSpecificString):
class
StreamToken
(
namedtuple
(
"
Token
"
,
(
"
events_key
"
,
"
presence_key
"
)
(
"
events_key
"
,
"
presence_key
"
,
"
typing_key
"
)
)
):
_SEPARATOR
=
"
_
"
...
...
This diff is collapsed.
Click to expand it.
tests/rest/test_presence.py
+
5
−
3
View file @
6dd50da5
...
...
@@ -295,7 +295,9 @@ class PresenceEventStreamTestCase(unittest.TestCase):
# all be ours
# I'll already get my own presence state change
self
.
assertEquals
({
"
start
"
:
"
0_1
"
,
"
end
"
:
"
0_1
"
,
"
chunk
"
:
[]},
response
)
self
.
assertEquals
({
"
start
"
:
"
0_1_0
"
,
"
end
"
:
"
0_1_0
"
,
"
chunk
"
:
[]},
response
)
self
.
mock_datastore
.
set_presence_state
.
return_value
=
defer
.
succeed
(
{
"
state
"
:
ONLINE
})
...
...
@@ -306,10 +308,10 @@ class PresenceEventStreamTestCase(unittest.TestCase):
state
=
{
"
state
"
:
ONLINE
})
(
code
,
response
)
=
yield
self
.
mock_resource
.
trigger
(
"
GET
"
,
"
/events?from=0_1&timeout=0
"
,
None
)
"
/events?from=0_1
_0
&timeout=0
"
,
None
)
self
.
assertEquals
(
200
,
code
)
self
.
assertEquals
({
"
start
"
:
"
0_1
"
,
"
end
"
:
"
0_2
"
,
"
chunk
"
:
[
self
.
assertEquals
({
"
start
"
:
"
0_1
_0
"
,
"
end
"
:
"
0_2
_0
"
,
"
chunk
"
:
[
{
"
type
"
:
"
m.presence
"
,
"
content
"
:
{
"
user_id
"
:
"
@banana:test
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment