@@ -559,6 +559,7 @@ const decodeQuotedContext = async (
559559 parentRemoteJid : string ,
560560 parentSender ?: SenderInfo ,
561561 parentRoomName ?: ( ) => Promise < string | null > ,
562+ parentFromMe ?: boolean ,
562563) : Promise < MessageContext | null > => {
563564 try {
564565 if ( contextInfo == null ) return null
@@ -583,22 +584,38 @@ const decodeQuotedContext = async (
583584 if ( typeof quoted . key . remoteJid !== 'string' || quoted . key . remoteJid . length === 0 ) return null
584585
585586 const author = quoted . key . participant
586- const isSelf =
587- typeof author === 'string' &&
588- ( ( ctx . selfJid . length > 0 && normalizedEquals ( author , ctx . selfJid ) ) ||
589- ( ctx . selfLid != null && normalizedEquals ( author , ctx . selfLid ) ) )
590587 const parentIsGroup = isGroupJid ( parentRemoteJid )
591588
592589 let pushName = quoted . sender ?. pushName
593- if ( isSelf ) {
594- quoted . key . fromMe = true
595- if ( ctx . selfJid . length > 0 ) quoted . key . participant = ctx . selfJid
596- if ( ctx . selfLid != null ) quoted . key . participantAlt = ctx . selfLid
597- if ( pushName == null ) pushName = ctx . selfName
598- } else if ( parentSender != null && ( ! parentIsGroup || sameAuthor ( quoted . sender , parentSender ) ) ) {
599- if ( parentSender . pn != null ) quoted . key . participant = parentSender . pn
600- if ( parentSender . lid != null ) quoted . key . participantAlt = parentSender . lid
601- if ( pushName == null ) pushName = parentSender . pushName
590+
591+ if ( ! parentIsGroup && ( author == null || author . length === 0 ) ) {
592+ if ( parentFromMe === true ) {
593+ quoted . key . participant = parentRemoteJid
594+ if ( pushName == null && parentSender != null && sameAuthor ( { jid : parentRemoteJid } , parentSender ) ) {
595+ pushName = parentSender . pushName
596+ }
597+ } else {
598+ quoted . key . fromMe = true
599+ if ( ctx . selfJid . length > 0 ) quoted . key . participant = ctx . selfJid
600+ if ( ctx . selfLid != null ) quoted . key . participantAlt = ctx . selfLid
601+ if ( pushName == null ) pushName = ctx . selfName
602+ }
603+ } else {
604+ const isSelf =
605+ typeof author === 'string' &&
606+ ( ( ctx . selfJid . length > 0 && normalizedEquals ( author , ctx . selfJid ) ) ||
607+ ( ctx . selfLid != null && normalizedEquals ( author , ctx . selfLid ) ) )
608+
609+ if ( isSelf ) {
610+ quoted . key . fromMe = true
611+ if ( ctx . selfJid . length > 0 ) quoted . key . participant = ctx . selfJid
612+ if ( ctx . selfLid != null ) quoted . key . participantAlt = ctx . selfLid
613+ if ( pushName == null ) pushName = ctx . selfName
614+ } else if ( parentSender != null && sameAuthor ( quoted . sender , parentSender ) ) {
615+ if ( parentSender . pn != null ) quoted . key . participant = parentSender . pn
616+ if ( parentSender . lid != null ) quoted . key . participantAlt = parentSender . lid
617+ if ( pushName == null ) pushName = parentSender . pushName
618+ }
602619 }
603620
604621 const qm = contextInfo . quotedMessage as WAMessage [ 'message' ]
@@ -680,7 +697,7 @@ const buildContext = (
680697 ctx . resolveReceiverName ?? ( ( ) => Promise . resolve ( null ) )
681698
682699 const resolveReplied = ( ) : Promise < MessageContext | null > =>
683- decodeQuotedContext ( contextInfo , ctx , jid , sender , resolveRoomName )
700+ decodeQuotedContext ( contextInfo , ctx , jid , sender , resolveRoomName , key . fromMe === true )
684701
685702 const replyTarget = jid . length > 0 ? jid : ( sender . pn ?? sender . jid )
686703 const reply = ( content : string , opts ?: TextOptions ) : Promise < WAMessageKey > => {
0 commit comments