-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Add config limits for portal rooms #469
Open
Half-Shot
wants to merge
9
commits into
mautrix:master
Choose a base branch
from
Half-Shot:hs/portal-limit
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2f61a59
Add config limits for portal rooms
Half-Shot 8196031
Update mautrix_telegram/portal/base.py
Half-Shot 6754c3f
Stop portals from being created if the limit is reached
Half-Shot b4991da
Fix botched rebase
Half-Shot e317fcf
Update mautrix_telegram/example-config.yaml
Half-Shot fe6066e
Update mautrix_telegram/portal/base.py
Half-Shot d5e8ed5
Update mautrix_telegram/portal/base.py
Half-Shot 59cb717
Fix mistaken commit
Half-Shot acc8db9
Feh!
Half-Shot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
from typing import Optional, Iterable | ||
|
||
from sqlalchemy import Column, Integer, String, Boolean, Text, func, sql | ||
from sqlalchemy import Column, Integer, String, Boolean, Text, func, sql, select | ||
|
||
from mautrix.types import RoomID, ContentURI | ||
from mautrix.util.db import Base | ||
|
@@ -54,8 +54,13 @@ def find_private_chats(cls, tg_receiver: TelegramID) -> Iterable['Portal']: | |
yield from cls._select_all(cls.c.tg_receiver == tg_receiver, cls.c.peer_type == "user") | ||
|
||
@classmethod | ||
def get_by_mxid(cls, mxid: RoomID) -> Optional['Portal']: | ||
return cls._select_one_or_none(cls.c.mxid == mxid) | ||
def count(cls) -> int: | ||
rows = cls.db.execute(select([func.count()])) | ||
try: | ||
count, = next(rows) | ||
return count | ||
except StopIteration: | ||
return 0 | ||
|
||
@classmethod | ||
def get_by_username(cls, username: str) -> Optional['Portal']: | ||
|
@@ -64,3 +69,7 @@ def get_by_username(cls, username: str) -> Optional['Portal']: | |
@classmethod | ||
def all(cls) -> Iterable['Portal']: | ||
yield from cls._select_all() | ||
|
||
@classmethod | ||
def get_by_mxid(cls, mxid: RoomID) -> Integer: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems to have been changed accidentally |
||
return cls._select_one_or_none(cls.c.mxid == mxid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Baby's first Python commits (don't commit blindly):
Please test this. I haven't actually run this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No good unfortunately,
AttributeError: 'Engine' object has no attribute 'query'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The table to count rows in probably needs to be specified somewhere 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh derp, I thought that was implied somewhere