Merge lp:~tiagosh/history-service/manually_add_self_contact_to_participants into lp:history-service

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 200
Merged at revision: 204
Proposed branch: lp:~tiagosh/history-service/manually_add_self_contact_to_participants
Merge into: lp:history-service
Prerequisite: lp:~tiagosh/history-service/generate-eventIds
Diff against target: 80 lines (+18/-13)
2 files modified
daemon/historydaemon.cpp (+17/-13)
daemon/historydaemon.h (+1/-0)
To merge this branch: bzr merge lp:~tiagosh/history-service/manually_add_self_contact_to_participants
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+265071@code.launchpad.net

This proposal supersedes a proposal from 2015-07-13.

Commit message

Manually add self id to participants list if needed.

Description of the change

Manually add self id to participants list if needed.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote : Posted in a previous version of this proposal

73 + QStringList participantsFromChannel(const Tp::TextChannelPtr &textChannel);

Can you make it either const or static? I think static would be better for this case

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote : Posted in a previous version of this proposal

> 73 + QStringList participantsFromChannel(const Tp::TextChannelPtr
> &textChannel);
>
> Can you make it either const or static? I think static would be better for
> this case

Done

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'daemon/historydaemon.cpp'
2--- daemon/historydaemon.cpp 2015-07-16 22:16:44 +0000
3+++ daemon/historydaemon.cpp 2015-07-16 22:16:44 +0000
4@@ -76,6 +76,20 @@
5 return self;
6 }
7
8+QStringList HistoryDaemon::participantsFromChannel(const Tp::TextChannelPtr &textChannel)
9+{
10+ QStringList participants;
11+ Q_FOREACH(const Tp::ContactPtr contact, textChannel->groupContacts(false)) {
12+ participants << contact->id();
13+ }
14+
15+ if (participants.isEmpty() && textChannel->targetHandleType() == Tp::HandleTypeContact &&
16+ textChannel->targetContact() == textChannel->connection()->selfContact()) {
17+ participants << textChannel->targetContact()->id();
18+ }
19+ return participants;
20+}
21+
22 QVariantMap HistoryDaemon::threadForParticipants(const QString &accountId,
23 History::EventType type,
24 const QStringList &participants,
25@@ -398,10 +412,7 @@
26 if (message.isDeliveryReport() && message.deliveryDetails().hasOriginalToken()) {
27 // at this point we assume the delivery report is for a message that was already
28 // sent and properly saved at our database, so we can safely get it here to update
29- QStringList participants;
30- Q_FOREACH(const Tp::ContactPtr contact, textChannel->groupContacts(false)) {
31- participants << contact->id();
32- }
33+ QStringList participants = participantsFromChannel(textChannel);
34
35 QVariantMap thread = threadForParticipants(textChannel->property(History::FieldAccountId).toString(),
36 History::EventTypeText,
37@@ -455,10 +466,7 @@
38 return;
39 }
40
41- QStringList participants;
42- Q_FOREACH(const Tp::ContactPtr contact, textChannel->groupContacts(false)) {
43- participants << contact->id();
44- }
45+ QStringList participants = participantsFromChannel(textChannel);
46
47 QVariantMap thread = threadForParticipants(textChannel->property(History::FieldAccountId).toString(),
48 History::EventTypeText,
49@@ -543,7 +551,7 @@
50 void HistoryDaemon::onMessageSent(const Tp::TextChannelPtr textChannel, const Tp::Message &message, const QString &messageToken)
51 {
52 qDebug() << __PRETTY_FUNCTION__;
53- QStringList participants;
54+ QStringList participants = participantsFromChannel(textChannel);
55 QList<QVariantMap> attachments;
56 History::MessageType type = History::MessageTypeText;
57 int count = 1;
58@@ -556,10 +564,6 @@
59 eventId = messageToken;
60 }
61
62- Q_FOREACH(const Tp::ContactPtr contact, textChannel->groupContacts(false)) {
63- participants << contact->id();
64- }
65-
66 QVariantMap thread = threadForParticipants(textChannel->property(History::FieldAccountId).toString(),
67 History::EventTypeText,
68 participants,
69
70=== modified file 'daemon/historydaemon.h'
71--- daemon/historydaemon.h 2013-11-29 16:14:49 +0000
72+++ daemon/historydaemon.h 2015-07-16 22:16:44 +0000
73@@ -37,6 +37,7 @@
74
75 static HistoryDaemon *instance();
76
77+ static QStringList participantsFromChannel(const Tp::TextChannelPtr &textChannel);
78 QVariantMap threadForParticipants(const QString &accountId,
79 History::EventType type,
80 const QStringList &participants,

Subscribers

People subscribed via source and target branches