Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
2c41aff3af
@ -33,7 +33,6 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import ch.dissem.apps.abit.R;
|
import ch.dissem.apps.abit.R;
|
||||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
|
||||||
import ch.dissem.bitmessage.entity.Plaintext;
|
import ch.dissem.bitmessage.entity.Plaintext;
|
||||||
import ch.dissem.bitmessage.entity.valueobject.InventoryVector;
|
import ch.dissem.bitmessage.entity.valueobject.InventoryVector;
|
||||||
import ch.dissem.bitmessage.entity.valueobject.Label;
|
import ch.dissem.bitmessage.entity.valueobject.Label;
|
||||||
@ -242,25 +241,12 @@ public class AndroidMessageRepository extends AbstractMessageRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(Plaintext message) {
|
public void save(Plaintext message) {
|
||||||
|
saveContactIfNecessary(message.getFrom());
|
||||||
|
saveContactIfNecessary(message.getTo());
|
||||||
SQLiteDatabase db = sql.getWritableDatabase();
|
SQLiteDatabase db = sql.getWritableDatabase();
|
||||||
try {
|
try {
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
|
|
||||||
// save from address if necessary
|
|
||||||
BitmessageAddress savedAddress = ctx.getAddressRepository().getAddress(message
|
|
||||||
.getFrom().getAddress());
|
|
||||||
if (message.getId() == null) {
|
|
||||||
if (savedAddress == null) {
|
|
||||||
ctx.getAddressRepository().save(message.getFrom());
|
|
||||||
} else if (savedAddress.getPubkey() == null) {
|
|
||||||
savedAddress.setPubkey(message.getFrom().getPubkey());
|
|
||||||
ctx.getAddressRepository().save(savedAddress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (savedAddress != null) {
|
|
||||||
message.getFrom().setAlias(savedAddress.getAlias());
|
|
||||||
}
|
|
||||||
|
|
||||||
// save message
|
// save message
|
||||||
if (message.getId() == null) {
|
if (message.getId() == null) {
|
||||||
insert(db, message);
|
insert(db, message);
|
||||||
|
Loading…
Reference in New Issue
Block a user