Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfeaf6f4ea |
+19
-2
@@ -558,8 +558,8 @@ func (database *Database) CreateOrJoinChannel(
|
|||||||
// ErrInviteOnlyChannel when the channel is +i and the
|
// ErrInviteOnlyChannel when the channel is +i and the
|
||||||
// session has no invite, ErrBadChannelKey when suppliedKey
|
// session has no invite, ErrBadChannelKey when suppliedKey
|
||||||
// is not the +k key, or ErrChannelIsFull when the channel
|
// is not the +k key, or ErrChannelIsFull when the channel
|
||||||
// has at least its +l number of members. It returns nil
|
// has its +l number of members. It returns nil when none
|
||||||
// when none applies.
|
// applies.
|
||||||
func checkJoinRestrictions(
|
func checkJoinRestrictions(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
transaction *sql.Tx,
|
transaction *sql.Tx,
|
||||||
@@ -2304,6 +2304,23 @@ func (database *Database) HasChannelInvite(
|
|||||||
return count > 0, nil
|
return count > 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearChannelInvite removes a session's invite to a
|
||||||
|
// channel (called after successful JOIN).
|
||||||
|
func (database *Database) ClearChannelInvite(
|
||||||
|
ctx context.Context,
|
||||||
|
channelID, sessionID int64,
|
||||||
|
) error {
|
||||||
|
_, err := database.conn.ExecContext(ctx,
|
||||||
|
`DELETE FROM channel_invites
|
||||||
|
WHERE channel_id = ? AND session_id = ?`,
|
||||||
|
channelID, sessionID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("clear invite: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// --- Tier 2: Secret (+s) ---
|
// --- Tier 2: Secret (+s) ---
|
||||||
|
|
||||||
// IsChannelSecret checks if a channel has +s mode.
|
// IsChannelSecret checks if a channel has +s mode.
|
||||||
|
|||||||
@@ -1342,6 +1342,17 @@ func TestChannelInviteCRUD(t *testing.T) {
|
|||||||
if !has {
|
if !has {
|
||||||
t.Fatal("should have invite")
|
t.Fatal("should have invite")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear invite.
|
||||||
|
err = database.ClearChannelInvite(ctx, chID, sid)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
has, _ = database.HasChannelInvite(ctx, chID, sid)
|
||||||
|
if has {
|
||||||
|
t.Fatal("invite should be cleared")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestChannelSecret(t *testing.T) {
|
func TestChannelSecret(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user