Skip to content

Commit

Permalink
fix ReadState error?
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanUC committed Jul 27, 2024
1 parent bc515b5 commit 67cac18
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ protobuf = "4.25.3"
python-dateutil = "2.9.0.post0"
cryptography = "43.0.0"
emoji = "2.12.1"
six = "1.16.0"
bcrypt = "4.2.0"
quart-schema = "0.20.0"
pydantic = "2.8.2"
Expand Down
3 changes: 1 addition & 2 deletions yepcord/rest_api/routes/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def api_auth_locationmetadata():
return {
"consent_required": False,
"country_code": "US",
"promotional_email_opt_in": {"required": True, "pre_checked": False}
"promotional_email_opt_in": {"required": False, "pre_checked": False}
}


Expand Down Expand Up @@ -248,6 +248,5 @@ async def instance_info():
"OLD_USERNAMES",
"REMOTE_AUTH_V1",
"REMOTE_AUTH_V2",
"SETTINGS_PROTO",
],
}
2 changes: 1 addition & 1 deletion yepcord/yepcord/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ async def getGuildMembersGw(self, guild: Guild, query: str, limit: int, user_ids
# noinspection PyUnresolvedReferences
return await GuildMember.filter(
Q(guild=guild) &
(Q(nick__startswith=query) | Q(user__userdatas__username__istartswith=query)) #&
(Q(nick__startswith=query) | Q(user__userdatas__username__istartswith=query)) # &
#((GuildMember.user.id in user_ids) if user_ids else (GuildMember.user.id not in [0]))
).select_related("user").limit(limit).all()

Expand Down
5 changes: 5 additions & 0 deletions yepcord/yepcord/models/readstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class ReadState(Model):
last_read_id: int = fields.BigIntField()
count: int = fields.IntField()

class Meta:
unique_together = (
("channel", "user"),
)

async def ds_json(self) -> dict:
last_pin = await getCore().getLastPinnedMessage(self.channel)
last_pin_ts = last_pin.pinned_timestamp.strftime("%Y-%m-%dT%H:%M:%S+00:00") if last_pin is not None else None
Expand Down
6 changes: 3 additions & 3 deletions yepcord/yepcord/mq_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from faststream.nats import NatsBroker
from websockets.client import connect
from websockets.legacy.client import WebSocketClientProtocol
from websockets.legacy.server import WebSocketServer
from websockets.legacy.server import WebSocketServer, WebSocketServerProtocol
from websockets.protocol import State
from websockets.server import serve

Expand All @@ -38,7 +38,7 @@
class WsServer:
def __init__(self, url: str):
self._url = url
self._connections: set[WebSocketClientProtocol] = set()
self._connections: set[WebSocketServerProtocol] = set()
self._server: WebSocketServer | None = None
self._run_event = asyncio.Event()

Expand All @@ -48,7 +48,7 @@ async def _broadcast(self, message: str, exclude=None) -> None: # pragma: no co
continue
await connection.send(message)

async def _handle(self, client) -> None:
async def _handle(self, client: WebSocketServerProtocol) -> None:
self._connections.add(client)
async for message in client:
await self._broadcast(message, exclude=client)
Expand Down

0 comments on commit 67cac18

Please sign in to comment.