Search in sources :

Example 1 with PendingMessage

use of im.actor.core.modules.messaging.actions.entity.PendingMessage in project actor-platform by actorapp.

the class SenderActor method onFileUploadError.

private void onFileUploadError(long rid) {
    PendingMessage msg = findPending(rid);
    if (msg == null) {
        return;
    }
    self().send(new MessageError(msg.getPeer(), msg.getRid()));
    fileUplaodingWakeLocks.remove(rid).releaseLock();
}
Also used : PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage)

Example 2 with PendingMessage

use of im.actor.core.modules.messaging.actions.entity.PendingMessage in project actor-platform by actorapp.

the class SenderActor method doSendText.

// Sending text
public void doSendText(@NotNull Peer peer, @NotNull String text, @Nullable ArrayList<Integer> mentions, /*Ignored*/
@Nullable String markDownText, boolean autoDetect) {
    text = text.trim();
    long rid = RandomUtils.nextRid();
    long date = createPendingDate();
    long sortDate = date + 365 * 24 * 60 * 60 * 1000L;
    if (autoDetect) {
        mentions = new ArrayList<>();
        if (peer.getPeerType() == PeerType.GROUP) {
            Group group = getGroup(peer.getPeerId());
            String lowText = text.toLowerCase();
            if (group.getMembers() != null) {
                for (GroupMember member : group.getMembers()) {
                    User user = getUser(member.getUid());
                    if (user.getNick() != null) {
                        String nick = "@" + user.getNick().toLowerCase();
                        // TODO: Better filtering
                        if (lowText.contains(nick + ":") || lowText.contains(nick + " ") || lowText.contains(" " + nick) || lowText.endsWith(nick) || lowText.equals(nick)) {
                            mentions.add(user.getUid());
                        }
                    }
                }
            }
        }
    }
    TextContent content = TextContent.create(text, null, mentions);
    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 : Group(im.actor.core.entity.Group) GroupMember(im.actor.core.entity.GroupMember) User(im.actor.core.entity.User) 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) TextContent(im.actor.core.entity.content.TextContent) PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage)

Example 3 with PendingMessage

use of im.actor.core.modules.messaging.actions.entity.PendingMessage in project actor-platform by actorapp.

the class SenderActor method doSendDocument.

// Sending documents
public void doSendDocument(Peer peer, String fileName, String mimeType, int fileSize, FastThumb fastThumb, String descriptor) {
    long rid = RandomUtils.nextRid();
    long date = createPendingDate();
    long sortDate = date + 365 * 24 * 60 * 60 * 1000L;
    DocumentContent documentContent = DocumentContent.createLocal(fileName, fileSize, descriptor, mimeType, fastThumb);
    Message message = new Message(rid, sortDate, date, myUid(), MessageState.PENDING, documentContent);
    context().getMessagesModule().getRouter().onOutgoingMessage(peer, message);
    pendingMessages.getPendingMessages().add(new PendingMessage(peer, rid, documentContent));
    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) DocumentContent(im.actor.core.entity.content.DocumentContent) PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage)

Example 4 with PendingMessage

use of im.actor.core.modules.messaging.actions.entity.PendingMessage in project actor-platform by actorapp.

the class SenderActor method doSendJson.

public void doSendJson(Peer peer, JsonContent 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 5 with PendingMessage

use of im.actor.core.modules.messaging.actions.entity.PendingMessage in project actor-platform by actorapp.

the class SenderActor method onFileUploaded.

private void onFileUploaded(long rid, FileReference fileReference) {
    PendingMessage msg = findPending(rid);
    if (msg == null) {
        return;
    }
    pendingMessages.getPendingMessages().remove(msg);
    AbsContent nContent;
    if (msg.getContent() instanceof PhotoContent) {
        PhotoContent basePhotoContent = (PhotoContent) msg.getContent();
        nContent = PhotoContent.createRemotePhoto(fileReference, basePhotoContent.getW(), basePhotoContent.getH(), basePhotoContent.getFastThumb());
    } else if (msg.getContent() instanceof VideoContent) {
        VideoContent baseVideoContent = (VideoContent) msg.getContent();
        nContent = VideoContent.createRemoteVideo(fileReference, baseVideoContent.getW(), baseVideoContent.getH(), baseVideoContent.getDuration(), baseVideoContent.getFastThumb());
    } else if (msg.getContent() instanceof VoiceContent) {
        VoiceContent baseVoiceContent = (VoiceContent) msg.getContent();
        nContent = VoiceContent.createRemoteAudio(fileReference, baseVoiceContent.getDuration());
    } else if (msg.getContent() instanceof AnimationContent) {
        AnimationContent baseAnimcationContent = (AnimationContent) msg.getContent();
        nContent = AnimationContent.createRemoteAnimation(fileReference, baseAnimcationContent.getW(), baseAnimcationContent.getH(), baseAnimcationContent.getFastThumb());
    } else if (msg.getContent() instanceof DocumentContent) {
        DocumentContent baseDocContent = (DocumentContent) msg.getContent();
        nContent = DocumentContent.createRemoteDocument(fileReference, baseDocContent.getFastThumb());
    } else {
        return;
    }
    pendingMessages.getPendingMessages().add(new PendingMessage(msg.getPeer(), msg.getRid(), nContent));
    context().getMessagesModule().getRouter().onContentChanged(msg.getPeer(), msg.getRid(), nContent);
    performSendContent(msg.getPeer(), rid, nContent);
    fileUplaodingWakeLocks.remove(rid).releaseLock();
}
Also used : VideoContent(im.actor.core.entity.content.VideoContent) VoiceContent(im.actor.core.entity.content.VoiceContent) DocumentContent(im.actor.core.entity.content.DocumentContent) AbsContent(im.actor.core.entity.content.AbsContent) AnimationContent(im.actor.core.entity.content.AnimationContent) PendingMessage(im.actor.core.modules.messaging.actions.entity.PendingMessage) PhotoContent(im.actor.core.entity.content.PhotoContent)

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