Search in sources :

Example 11 with PendingMessage

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);
}
Also used : LocationContent(im.actor.core.entity.content.LocationContent) PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage) ApiTextMessage(im.actor.core.api.ApiTextMessage) Message(im.actor.core.entity.Message) ApiDocumentMessage(im.actor.core.api.ApiDocumentMessage) RequestSendMessage(im.actor.core.api.rpc.RequestSendMessage) ApiMessage(im.actor.core.api.ApiMessage) ApiJsonMessage(im.actor.core.api.ApiJsonMessage) PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage)

Example 12 with PendingMessage

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);
}
Also used : StickerContent(im.actor.core.entity.content.StickerContent) PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage) ApiTextMessage(im.actor.core.api.ApiTextMessage) Message(im.actor.core.entity.Message) ApiDocumentMessage(im.actor.core.api.ApiDocumentMessage) RequestSendMessage(im.actor.core.api.rpc.RequestSendMessage) ApiMessage(im.actor.core.api.ApiMessage) ApiJsonMessage(im.actor.core.api.ApiJsonMessage) PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage)

Example 13 with PendingMessage

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);
}
Also used : PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage) ApiTextMessage(im.actor.core.api.ApiTextMessage) Message(im.actor.core.entity.Message) ApiDocumentMessage(im.actor.core.api.ApiDocumentMessage) RequestSendMessage(im.actor.core.api.rpc.RequestSendMessage) ApiMessage(im.actor.core.api.ApiMessage) ApiJsonMessage(im.actor.core.api.ApiJsonMessage) PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage)

Example 14 with PendingMessage

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);
}
Also used : PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage) ApiTextMessage(im.actor.core.api.ApiTextMessage) Message(im.actor.core.entity.Message) ApiDocumentMessage(im.actor.core.api.ApiDocumentMessage) RequestSendMessage(im.actor.core.api.rpc.RequestSendMessage) ApiMessage(im.actor.core.api.ApiMessage) ApiJsonMessage(im.actor.core.api.ApiJsonMessage) AnimationContent(im.actor.core.entity.content.AnimationContent) PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage)

Example 15 with PendingMessage

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();
    }
}
Also used : PendingMessagesStorage(im.actor.core.modules.messaging.actions.entity.PendingMessagesStorage) DocumentContent(im.actor.core.entity.content.DocumentContent) FileLocalSource(im.actor.core.entity.content.FileLocalSource) List(java.util.List) ArrayList(java.util.ArrayList) IOException(java.io.IOException) TextContent(im.actor.core.entity.content.TextContent) PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage)

Aggregations

PendingMessage (im.actor.core.modules.messaging.actions.entity.PendingMessage)15 ApiDocumentMessage (im.actor.core.api.ApiDocumentMessage)11 ApiJsonMessage (im.actor.core.api.ApiJsonMessage)11 ApiMessage (im.actor.core.api.ApiMessage)11 ApiTextMessage (im.actor.core.api.ApiTextMessage)11 RequestSendMessage (im.actor.core.api.rpc.RequestSendMessage)11 Message (im.actor.core.entity.Message)11 DocumentContent (im.actor.core.entity.content.DocumentContent)3 AnimationContent (im.actor.core.entity.content.AnimationContent)2 PhotoContent (im.actor.core.entity.content.PhotoContent)2 TextContent (im.actor.core.entity.content.TextContent)2 VideoContent (im.actor.core.entity.content.VideoContent)2 VoiceContent (im.actor.core.entity.content.VoiceContent)2 Group (im.actor.core.entity.Group)1 GroupMember (im.actor.core.entity.GroupMember)1 User (im.actor.core.entity.User)1 AbsContent (im.actor.core.entity.content.AbsContent)1 ContactContent (im.actor.core.entity.content.ContactContent)1 FileLocalSource (im.actor.core.entity.content.FileLocalSource)1 LocationContent (im.actor.core.entity.content.LocationContent)1