Fixed issue #1314. re-sent retained messages when create/replace Subscription

- re-sent message when create a new Subscription relationship
- re-sent message when replace an existed Subscription with different Qos
This commit is contained in:
HeeeJianBo 2017-10-31 13:23:54 +08:00
parent 586c3a243a
commit 84d8eae37e
1 changed files with 2 additions and 1 deletions

View File

@ -389,14 +389,15 @@ handle_cast({subscribe, _From, TopicTable, AckFun},
SubMap;
{ok, OldQos} ->
emqttd:setqos(Topic, ClientId, NewQos),
emqttd_hooks:run('session.subscribed', [ClientId, Username], {Topic, Opts}),
?LOG(warning, "Duplicated subscribe ~s, old_qos=~w, new_qos=~w",
[Topic, OldQos, NewQos], State),
maps:put(Topic, NewQos, SubMap);
error ->
emqttd:subscribe(Topic, ClientId, Opts),
emqttd_hooks:run('session.subscribed', [ClientId, Username], {Topic, Opts}),
maps:put(Topic, NewQos, SubMap)
end,
emqttd_hooks:run('session.subscribed', [ClientId, Username], {Topic, Opts}),
{[NewQos|QosAcc], SubMap1}
end, {[], Subscriptions}, TopicTable),
AckFun(lists:reverse(GrantedQos)),