]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Send the correct join timestamp on a delayed join message.
authorSadie Powell <sadie@witchery.services>
Sat, 22 May 2021 03:58:41 +0000 (04:58 +0100)
committerSadie Powell <sadie@witchery.services>
Sat, 22 May 2021 03:58:41 +0000 (04:58 +0100)
src/modules/m_delayjoin.cpp

index d1c69069be674485457ebd703a3e7d7b7503a658..55398710cf07070a94827edf03bf9f49fb206c73 100644 (file)
 
 #include "inspircd.h"
 #include "modules/ctctags.h"
+#include "modules/ircv3_servertime.h"
 #include "modules/names.h"
 
 class DelayJoinMode : public ModeHandler
 {
  private:
        LocalIntExt& unjoined;
+       IRCv3::ServerTime::API servertime;
 
  public:
        DelayJoinMode(Module* Parent, LocalIntExt& ext)
                : ModeHandler(Parent, "delayjoin", 'D', PARAM_NONE, MODETYPE_CHANNEL)
                , unjoined(ext)
+               , servertime(Parent)
        {
                ranktoset = ranktounset = OP_VALUE;
        }
@@ -56,6 +59,7 @@ namespace
  */
 class JoinHook : public ClientProtocol::EventHook
 {
+ private:
        const LocalIntExt& unjoined;
 
  public:
@@ -161,7 +165,7 @@ static void populate(CUList& except, Membership* memb)
 void ModuleDelayJoin::OnUserJoin(Membership* memb, bool sync, bool created, CUList& except)
 {
        if (memb->chan->IsModeSet(djm))
-               unjoined.set(memb, 1);
+               unjoined.set(memb, ServerInstance->Time());
 }
 
 void ModuleDelayJoin::OnUserPart(Membership* memb, std::string &partmessage, CUList& except)
@@ -209,13 +213,16 @@ void ModuleDelayJoin::OnUserMessage(User* user, const MessageTarget& target, con
 void DelayJoinMode::RevealUser(User* user, Channel* chan)
 {
        Membership* memb = chan->GetUser(user);
-       if (!memb || !unjoined.set(memb, 0))
+       time_t jointime = unjoined.set(memb, 0);
+       if (!memb || !jointime)
                return;
 
        /* Display the join to everyone else (the user who joined got it earlier) */
        CUList except_list;
        except_list.insert(user);
        ClientProtocol::Events::Join joinevent(memb);
+       if (servertime)
+               servertime->Set(joinevent, jointime);
        chan->Write(joinevent, 0, except_list);
 }