use of im.actor.core.modules.messaging.actions.entity.PendingMessage in project actor-platform by actorapp.
the class SenderActor method doSendLocation.
public void doSendLocation(@NotNull Peer peer, @NotNull Double longitude, @NotNull Double latitude, @Nullable String street, @Nullable String place) {
long rid = RandomUtils.nextRid();
long date = createPendingDate();
long sortDate = date + 365 * 24 * 60 * 60 * 1000L;
LocationContent content = LocationContent.create(longitude, latitude, street, place);
Message message = new Message(rid, sortDate, date, myUid(), MessageState.PENDING, content);
context().getMessagesModule().getRouter().onOutgoingMessage(peer, message);
pendingMessages.getPendingMessages().add(new PendingMessage(peer, rid, content));
savePending();
performSendContent(peer, rid, content);
}
use of im.actor.core.modules.messaging.actions.entity.PendingMessage in project actor-platform by actorapp.
the class SenderActor method doSendSticker.
// Sending sticker
public void doSendSticker(@NotNull Peer peer, @NotNull Sticker sticker) {
long rid = RandomUtils.nextRid();
long date = createPendingDate();
long sortDate = date + 365 * 24 * 60 * 60 * 1000L;
StickerContent content = StickerContent.create(sticker);
Message message = new Message(rid, sortDate, date, myUid(), MessageState.PENDING, content);
context().getMessagesModule().getRouter().onOutgoingMessage(peer, message);
pendingMessages.getPendingMessages().add(new PendingMessage(peer, rid, content));
savePending();
performSendContent(peer, rid, content);
}
use of im.actor.core.modules.messaging.actions.entity.PendingMessage in project actor-platform by actorapp.
the class SenderActor method doForwardContent.
public void doForwardContent(Peer peer, AbsContent content) {
long rid = RandomUtils.nextRid();
long date = createPendingDate();
long sortDate = date + 365 * 24 * 60 * 60 * 1000L;
Message message = new Message(rid, sortDate, date, myUid(), MessageState.PENDING, content);
context().getMessagesModule().getRouter().onOutgoingMessage(peer, message);
pendingMessages.getPendingMessages().add(new PendingMessage(peer, rid, content));
savePending();
performSendContent(peer, rid, content);
}
use of im.actor.core.modules.messaging.actions.entity.PendingMessage in project actor-platform by actorapp.
the class SenderActor method doSendAnimation.
public void doSendAnimation(Peer peer, String fileName, int w, int h, FastThumb fastThumb, String descriptor, int fileSize) {
long rid = RandomUtils.nextRid();
long date = createPendingDate();
long sortDate = date + 365 * 24 * 60 * 60 * 1000L;
AnimationContent animationContent = AnimationContent.createLocalAnimation(descriptor, fileName, fileSize, w, h, fastThumb);
Message message = new Message(rid, sortDate, date, myUid(), MessageState.PENDING, animationContent);
context().getMessagesModule().getRouter().onOutgoingMessage(peer, message);
pendingMessages.getPendingMessages().add(new PendingMessage(peer, rid, animationContent));
savePending();
performUploadFile(rid, descriptor, fileName);
}
use of im.actor.core.modules.messaging.actions.entity.PendingMessage in project actor-platform by actorapp.
the class SenderActor method preStart.
@Override
public void preStart() {
pendingMessages = new PendingMessagesStorage();
byte[] p = preferences().getBytes(PREFERENCES);
if (p != null) {
try {
pendingMessages = PendingMessagesStorage.fromBytes(p);
} catch (IOException e) {
e.printStackTrace();
}
}
boolean isChanged = false;
ArrayList<PendingMessage> messages = pendingMessages.getPendingMessages();
for (PendingMessage pending : messages.toArray(new PendingMessage[messages.size()])) {
if (pending.getContent() instanceof TextContent) {
performSendContent(pending.getPeer(), pending.getRid(), pending.getContent());
} else if (pending.getContent() instanceof DocumentContent) {
DocumentContent documentContent = (DocumentContent) pending.getContent();
if (documentContent.getSource() instanceof FileLocalSource) {
if (Storage.isFsPersistent()) {
performUploadFile(pending.getRid(), ((FileLocalSource) documentContent.getSource()).getFileDescriptor(), ((FileLocalSource) documentContent.getSource()).getFileName());
} else {
List<Long> rids = new ArrayList<>();
rids.add(pending.getRid());
context().getMessagesModule().getRouter().onMessagesDeleted(pending.getPeer(), rids);
pendingMessages.getPendingMessages().remove(pending);
isChanged = true;
}
} else {
performSendContent(pending.getPeer(), pending.getRid(), pending.getContent());
}
}
}
if (isChanged) {
savePending();
}
}
Aggregations