Don't attempt to retrieve ratings for anonymous messages.

This commit is contained in:
akwizgran
2011-09-19 16:25:49 +01:00
parent 44c8f9ceaa
commit 4b97be897e

View File

@@ -218,6 +218,7 @@ DatabaseCleaner.Callback {
* the sender and unseen by all other contacts, and returns true. * the sender and unseen by all other contacts, and returns true.
* <p> * <p>
* Locking: contacts read, messages write, messageStatuses write. * Locking: contacts read, messages write, messageStatuses write.
* @param sender may be null for a locally generated message.
*/ */
private boolean storeGroupMessage(T txn, Message m, ContactId sender) private boolean storeGroupMessage(T txn, Message m, ContactId sender)
throws DbException { throws DbException {
@@ -251,7 +252,8 @@ DatabaseCleaner.Callback {
private int calculateSendability(T txn, Message m) throws DbException { private int calculateSendability(T txn, Message m) throws DbException {
int sendability = 0; int sendability = 0;
// One point for a good rating // One point for a good rating
if(db.getRating(txn, m.getAuthor()) == Rating.GOOD) sendability++; AuthorId a = m.getAuthor();
if(a != null && db.getRating(txn, a) == Rating.GOOD) sendability++;
// One point per sendable child (backward inclusion) // One point per sendable child (backward inclusion)
sendability += db.getNumberOfSendableChildren(txn, m.getId()); sendability += db.getNumberOfSendableChildren(txn, m.getId());
return sendability; return sendability;