Fix rap handling and keep the value of retain flag in bridge mode

This commit is contained in:
zhouzb 2020-01-16 16:49:13 +08:00
parent 66a7845bdc
commit 3ee8d5c5ca
1 changed files with 4 additions and 4 deletions

View File

@ -516,12 +516,12 @@ enrich_subopts([{qos, SubQoS}|Opts], Msg = #message{qos = PubQoS},
enrich_subopts([{qos, SubQoS}|Opts], Msg = #message{qos = PubQoS},
Session = #session{upgrade_qos = false}) ->
enrich_subopts(Opts, Msg#message{qos = min(SubQoS, PubQoS)}, Session);
enrich_subopts([{rap, _}|Opts], Msg = #message{headers = #{retained := true}}, Session) ->
enrich_subopts(Opts, emqx_message:set_flag(retain, true, Msg), Session);
enrich_subopts([{rap, 0}|Opts], Msg, Session) ->
enrich_subopts(Opts, emqx_message:set_flag(retain, false, Msg), Session);
enrich_subopts([{rap, 1}|Opts], Msg, Session) ->
enrich_subopts(Opts, Msg, Session);
enrich_subopts([{rap, 0}|Opts], Msg = #message{headers = #{retained := true}}, Session = #session{}) ->
enrich_subopts(Opts, Msg, Session);
enrich_subopts([{rap, 0}|Opts], Msg = #message{flags = Flags}, Session) ->
enrich_subopts(Opts, Msg#message{flags = maps:put(retain, false, Flags)}, Session);
enrich_subopts([{subid, SubId}|Opts], Msg, Session) ->
Msg1 = emqx_message:set_header('Subscription-Identifier', SubId, Msg),
enrich_subopts(Opts, Msg1, Session).