diff --git a/golded3/gccfgg.cpp b/golded3/gccfgg.cpp index 6a706e5..4f79fa1 100644 --- a/golded3/gccfgg.cpp +++ b/golded3/gccfgg.cpp @@ -686,7 +686,7 @@ CfgGed::CfgGed() { adeptxbbsuserno = 0; addressbookadd = YES; addresslookupfirst = false; - akamatchfromto = false; + akamatchfromto = NO; areaautoid = AUTOID_LONG; areacopydirect = false; areacopyaddid = false; diff --git a/golded3/gccfgg1.cpp b/golded3/gccfgg1.cpp index 3dc6361..a450952 100644 --- a/golded3/gccfgg1.cpp +++ b/golded3/gccfgg1.cpp @@ -176,7 +176,7 @@ void CfgAkamatch() { // ------------------------------------------------------------------ void CfgAkamatchfromto() { - CFG->akamatchfromto = (0 != GetYesno(val)); + CFG->akamatchfromto = GetYesno(val); } // ------------------------------------------------------------------ diff --git a/golded3/gecfgg.h b/golded3/gecfgg.h index 4858b4e..9b8e662 100644 --- a/golded3/gecfgg.h +++ b/golded3/gecfgg.h @@ -140,7 +140,7 @@ public: int adeptxbbsuserno; std::vector aka; std::vector akamatch; - bool akamatchfromto; + int akamatchfromto; int areaautoid; Echo areacfmreplyto; bool areacopydirect; diff --git a/golded3/gelmsg.cpp b/golded3/gelmsg.cpp index 0f737aa..6bc5fc5 100644 --- a/golded3/gelmsg.cpp +++ b/golded3/gelmsg.cpp @@ -54,6 +54,14 @@ int Area::LoadHdr(GMsg* msg, ulong msgno, bool enable_recode) { msg->msgno = msgno; int retval = area->load_hdr(msg); + if (isecho()) + { + if (CFG->akamatchfromto && msg->dest.invalid()) + msg->dest = Aka().addr; + else if (CFG->akamatchfromto == ALWAYS) + msg->dest = Aka().addr; + } + // Don't translate charsets if we don't know charset // Currently, it only mime-decodes, so it's okay. if(retval and enable_recode) { @@ -84,6 +92,15 @@ int Area::LoadMsg(GMsg* msg, ulong msgno, int margin, int mode) { ResetMsg(msg); msg->msgno = msgno; if(msgno and area->load_msg(msg)) { + + if (isecho()) + { + if (CFG->akamatchfromto && msg->dest.invalid()) + msg->dest = Aka().addr; + else if (CFG->akamatchfromto == ALWAYS) + msg->dest = Aka().addr; + } + if(mode & (GMSG_COPY|GMSG_MOVE)) { if(not ((mode & GMSG_MOVE) and (mode & GMSG_UNS_NOT_RCV))) return true; diff --git a/golded3/gepost.cpp b/golded3/gepost.cpp index c4a162e..c742ea5 100644 --- a/golded3/gepost.cpp +++ b/golded3/gepost.cpp @@ -30,6 +30,7 @@ // ------------------------------------------------------------------ static std::vector post_xparea; +bool akamatchreply = false; // ------------------------------------------------------------------ @@ -873,11 +874,36 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) { if(AA->Akamatching()) { // ... but only if we did NOT change aka manually if(AA->Aka().addr.equals(AA->aka())) { + Addr aka_addr = AA->Aka().addr; + if (CFG->akamatchfromto) + { + bool useto = true; + std::vector::iterator a; + + for (a = CFG->aka.begin(); useto && (a != CFG->aka.end()); a++) + { + if(omsg->orig.equals(a->addr)) + useto = false; + } + + if (useto) + { + for (a = CFG->aka.begin(); a != CFG->aka.end(); a++) + if(omsg->dest.equals(a->addr)) + { + akamatchreply = true; + break; + } + } + } + + if (CFG->akamatchfromto && akamatchreply) aka_addr = omsg->dest; else aka_addr = AA->Aka().addr; + AkaMatch(&aka_addr, &omsg->orig); AA->SetAka(aka_addr); } @@ -1208,6 +1234,7 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) { // Restore original aka AA->SetAka(origaka); + akamatchreply = false; ResetMsg(omsg); ResetMsg(cmpmsg); diff --git a/golded3/geutil2.cpp b/golded3/geutil2.cpp index 04096b2..dcfcd1f 100644 --- a/golded3/geutil2.cpp +++ b/golded3/geutil2.cpp @@ -27,6 +27,8 @@ #include #include +extern bool akamatchreply; + // ------------------------------------------------------------------ @@ -215,7 +217,7 @@ int AkaMatch(ftn_addr* match, const ftn_addr* addr) { if(match->equals(a->addr)) { - if (CFG->akamatchfromto) + if (CFG->akamatchfromto && akamatchreply) return aka; else matchaka = aka;