-
Notifications
You must be signed in to change notification settings - Fork 152
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
optionally make users wait to join bridged rooms #1645
base: develop
Are you sure you want to change the base?
Changes from 7 commits
bf6d09c
c14c7c9
a6a4308
2304333
3cc0a91
bb9030b
eec46e2
07760d3
7fde752
4fae8fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -538,6 +538,38 @@ export class MatrixHandler { | |
} | ||
// get the virtual IRC user for this user | ||
promises.push((async () => { | ||
const entry = await this.ircBridge.getStore().getRoom(event.room_id, room.server.domain, room.channel); | ||
jesopo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// is this a portal room? | ||
const delayTime = ["alias", "join"].includes( | ||
(entry?.data?.origin as string|null) ?? "unknown" | ||
//TODO: pull these two numbers from the config file | ||
) | ||
? this.ircBridge.config.ircService.delayBridging?.portaled ?? 0 | ||
: this.ircBridge.config.ircService.delayBridging?.plumbed ?? 0; | ||
|
||
if (delayTime > 0) { | ||
let remaining = delayTime; | ||
const firstSeen = await this.ircBridge.getStore().getFirstSeenTimeForUser(user.getId()); | ||
if (firstSeen === null) { | ||
// jeepers. this shouldn't happen! | ||
} | ||
else { | ||
remaining = Math.max(0, (firstSeen + (delayTime * 1000)) - Date.now()); | ||
} | ||
|
||
if (remaining > 0) { | ||
await this.membershipQueue.leave( | ||
event.room_id, | ||
user.getId(), | ||
req, | ||
true, | ||
`Please wait ${remaining} seconds`, | ||
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. We probably need to let the user know why they are waiting :). Either a message to their admin room, or a link to a page. |
||
this.ircBridge.appServiceUserId, | ||
); | ||
return; | ||
} | ||
} | ||
|
||
let bridgedClient: BridgedClient|null = null; | ||
try { | ||
bridgedClient = await this.ircBridge.getBridgedClient( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,10 @@ export interface BridgeConfig { | |
inactiveAfterDays?: number; | ||
}; | ||
banLists?: MatrixBanSyncConfig; | ||
delayBridging?: { | ||
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. I think these need more descriptions about what they do. It might even make sense to have this go under the We should certainly make it obvious that these are seconds. |
||
plumbed: number, | ||
portaled: number, | ||
}; | ||
}; | ||
sentry?: { | ||
enabled: boolean; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PoolClient } from "pg"; | ||
|
||
export async function runSchema(connection: PoolClient) { | ||
await connection.query(` | ||
ALTER TABLE last_seen ADD COLUMN first BIGINT; | ||
ALTER TABLE last_seen RENAME COLUMN ts TO last; | ||
UPDATE last_seen SET first = last; | ||
ALTER TABLE last_seen ALTER COLUMN first SET NOT NULL; | ||
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. That might explode for all the existing items that don't have a value set. 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. see the line above it; we backfill |
||
`); | ||
} |
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.
I'd make this it's own function inside datastore personally, and have the logic for setting first seen time handled within. We might even be able to wrap the postgres stuff into one statement.