diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-11-02 13:28:55 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-11-02 13:28:55 +0100 |
commit | 30fc51c6ddca487a1b89da9ab0ab59da003aee36 (patch) | |
tree | 8727403ddfdc51441db940ba77d2cce6cea3ec66 /src/channels.cpp | |
parent | a6b53dbc3629eb329b5b77d81e81ced837d4dc66 (diff) |
Rewrite invite system
- Moved out of core, now lives entirely in core_channel
- Accessible using the provided API after including the appropriate header
- Invites are stored in an extension attached to LocalUser/Channel objects, they no longer need special handling when destroying these objects or when lowering TS
- Expiration of timed invites are implemented using Timers
- When creating a new invite let a non-timed invite override a timed one
Diffstat (limited to 'src/channels.cpp')
-rw-r--r-- | src/channels.cpp | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 58388bef5..6e3bc5e04 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -90,7 +90,6 @@ void Channel::CheckDestroy() FOREACH_MOD(OnChannelDelete, (this)); ServerInstance->chanlist.erase(iter); - ClearInvites(); ServerInstance->GlobalCulls.AddItem(this); } @@ -638,68 +637,3 @@ bool Membership::SetPrefix(PrefixMode* delta_mh, bool adding) modes.push_back(prefix); return adding; } - -void Invitation::Create(Channel* c, LocalUser* u, time_t timeout) -{ - if ((timeout != 0) && (ServerInstance->Time() >= timeout)) - // Expired, don't bother - return; - - ServerInstance->Logs->Log("INVITATION", LOG_DEBUG, "Invitation::Create chan=%s user=%s", c->name.c_str(), u->uuid.c_str()); - - Invitation* inv = Invitation::Find(c, u, false); - if (inv) - { - if ((inv->expiry == 0) || (inv->expiry > timeout)) - return; - inv->expiry = timeout; - ServerInstance->Logs->Log("INVITATION", LOG_DEBUG, "Invitation::Create changed expiry in existing invitation %p", (void*) inv); - } - else - { - inv = new Invitation(c, u, timeout); - c->invites.push_front(inv); - u->invites.push_front(inv); - ServerInstance->Logs->Log("INVITATION", LOG_DEBUG, "Invitation::Create created new invitation %p", (void*) inv); - } -} - -Invitation* Invitation::Find(Channel* c, LocalUser* u, bool check_expired) -{ - ServerInstance->Logs->Log("INVITATION", LOG_DEBUG, "Invitation::Find chan=%s user=%s check_expired=%d", c ? c->name.c_str() : "NULL", u ? u->uuid.c_str() : "NULL", check_expired); - - Invitation* result = NULL; - for (InviteList::iterator i = u->invites.begin(); i != u->invites.end(); ) - { - Invitation* inv = *i; - ++i; - - if ((check_expired) && (inv->expiry != 0) && (inv->expiry <= ServerInstance->Time())) - { - /* Expired invite, remove it. */ - std::string expiration = InspIRCd::TimeString(inv->expiry); - ServerInstance->Logs->Log("INVITATION", LOG_DEBUG, "Invitation::Find ecountered expired entry: %p expired %s", (void*) inv, expiration.c_str()); - delete inv; - } - else - { - /* Is it what we're searching for? */ - if (inv->chan == c) - { - result = inv; - break; - } - } - } - - ServerInstance->Logs->Log("INVITATION", LOG_DEBUG, "Invitation::Find result=%p", (void*) result); - return result; -} - -Invitation::~Invitation() -{ - // Remove this entry from both lists - chan->invites.erase(this); - user->invites.erase(this); - ServerInstance->Logs->Log("INVITEBASE", LOG_DEBUG, "Invitation::~ %p", (void*) this); -} |