Skip to content

Commit

Permalink
Remove server extension and handlers, not used anymore since the chat…
Browse files Browse the repository at this point in the history
… does not use websockets
  • Loading branch information
brichet committed Mar 15, 2024
1 parent 57214b0 commit 9f09f7e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 39 deletions.
3 changes: 1 addition & 2 deletions jupyter_collaboration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Any, Dict, List

from ._version import __version__ # noqa
from .app import CollaborativeChatExtension, YDocExtension
from .app import YDocExtension

def _jupyter_labextension_paths():
return [{"src": "labextension", "dest": "@jupyter/collaboration-extension"}]
Expand All @@ -13,5 +13,4 @@ def _jupyter_labextension_paths():
def _jupyter_server_extension_points() -> List[Dict[str, Any]]:
return [
{"module": "jupyter_collaboration", "app": YDocExtension},
{"module": "jupyter_chat", "app": CollaborativeChatExtension},
]
16 changes: 1 addition & 15 deletions jupyter_collaboration/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from jupyter_server.extension.application import ExtensionApp
from pycrdt_websocket.ystore import BaseYStore
from traitlets import Bool, Float, Type
from jupyter_chat import ChatExtension
from jupyter_chat.handlers import GlobalConfigHandler, ChatHistoryHandler

from .handlers import CollaborativeChatHandler, DocSessionHandler, YDocWebSocketHandler
from .handlers import DocSessionHandler, YDocWebSocketHandler
from .loaders import FileLoaderMapping
from .stores import SQLiteYStore
from .utils import EVENTS_SCHEMA_PATH
Expand Down Expand Up @@ -122,15 +120,3 @@ async def stop_extension(self):
],
timeout=3,
)


class CollaborativeChatExtension(ChatExtension):

def initialize_handlers(self):
self.handlers.extend([
(fr"{self.base_url}?", CollaborativeChatHandler),
(fr"{self.base_url}config/?", GlobalConfigHandler),
(fr"{self.base_url}history/?", ChatHistoryHandler)
])

self.log.debug("Collaborative Chat Handlers initialized")
22 changes: 0 additions & 22 deletions jupyter_collaboration/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,25 +384,3 @@ async def put(self, path):
)
self.set_status(201)
return self.finish(data)


class CollaborativeChatHandler(ChatHandler):

def get_chat_user(self) -> ChatUser:
"""Retrieves the current user from collaborative context."""

names = self.current_user.name.split(" ", maxsplit=2)
initials = getattr(self.current_user, "initials", None)
if not initials:
# compute default initials in case IdentityProvider doesn't
# return initials, e.g. JupyterHub (#302)
names = self.current_user.name.split(" ", maxsplit=2)
initials = "".join(
[(name.capitalize()[0] if len(name) > 0 else "") for name in names]
)
chat_user_kwargs = {
**asdict(self.current_user),
"initials": initials,
}

return ChatUser(**chat_user_kwargs)

0 comments on commit 9f09f7e

Please sign in to comment.