Java Code Examples for org.telegram.tgnet.TLRPC#DecryptedMessageAction

The following examples show how to use org.telegram.tgnet.TLRPC#DecryptedMessageAction . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private TLRPC.TL_messageService createServiceSecretMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.DecryptedMessageAction decryptedMessage) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();

    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = decryptedMessage;
    newMsg.local_id = newMsg.id = UserConfig.getInstance(currentAccount).getNewMessageId();
    newMsg.from_id = UserConfig.getInstance(currentAccount).getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    if (encryptedChat.participant_id == UserConfig.getInstance(currentAccount).getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    if (decryptedMessage instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || decryptedMessage instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
        newMsg.date = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
    } else {
        newMsg.date = 0;
    }
    newMsg.random_id = SendMessagesHelper.getInstance(currentAccount).getNextRandomId();
    UserConfig.getInstance(currentAccount).saveConfig(false);

    ArrayList<TLRPC.Message> arr = new ArrayList<>();
    arr.add(newMsg);
    MessagesStorage.getInstance(currentAccount).putMessages(arr, false, true, true, 0);

    return newMsg;
}
 
Example 2
Source File: SecretChatHelper.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private TLRPC.TL_messageService createServiceSecretMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.DecryptedMessageAction decryptedMessage) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();

    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = decryptedMessage;
    newMsg.local_id = newMsg.id = UserConfig.getInstance(currentAccount).getNewMessageId();
    newMsg.from_id = UserConfig.getInstance(currentAccount).getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    if (encryptedChat.participant_id == UserConfig.getInstance(currentAccount).getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    if (decryptedMessage instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || decryptedMessage instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
        newMsg.date = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
    } else {
        newMsg.date = 0;
    }
    newMsg.random_id = SendMessagesHelper.getInstance(currentAccount).getNextRandomId();
    UserConfig.getInstance(currentAccount).saveConfig(false);

    ArrayList<TLRPC.Message> arr = new ArrayList<>();
    arr.add(newMsg);
    MessagesStorage.getInstance(currentAccount).putMessages(arr, false, true, true, 0);

    return newMsg;
}
 
Example 3
Source File: SecretChatHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private TLRPC.TL_messageService createServiceSecretMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.DecryptedMessageAction decryptedMessage) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();

    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = decryptedMessage;
    newMsg.local_id = newMsg.id = getUserConfig().getNewMessageId();
    newMsg.from_id = getUserConfig().getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    if (encryptedChat.participant_id == getUserConfig().getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    if (decryptedMessage instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || decryptedMessage instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
        newMsg.date = getConnectionsManager().getCurrentTime();
    } else {
        newMsg.date = 0;
    }
    newMsg.random_id = getSendMessagesHelper().getNextRandomId();
    getUserConfig().saveConfig(false);

    ArrayList<TLRPC.Message> arr = new ArrayList<>();
    arr.add(newMsg);
    getMessagesStorage().putMessages(arr, false, true, true, 0, false);

    return newMsg;
}
 
Example 4
Source File: SecretChatHelper.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private TLRPC.TL_messageService createServiceSecretMessage(final TLRPC.EncryptedChat encryptedChat, TLRPC.DecryptedMessageAction decryptedMessage) {
    TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();

    newMsg.action = new TLRPC.TL_messageEncryptedAction();
    newMsg.action.encryptedAction = decryptedMessage;
    newMsg.local_id = newMsg.id = getUserConfig().getNewMessageId();
    newMsg.from_id = getUserConfig().getClientUserId();
    newMsg.unread = true;
    newMsg.out = true;
    newMsg.flags = TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
    newMsg.dialog_id = ((long) encryptedChat.id) << 32;
    newMsg.to_id = new TLRPC.TL_peerUser();
    newMsg.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
    if (encryptedChat.participant_id == getUserConfig().getClientUserId()) {
        newMsg.to_id.user_id = encryptedChat.admin_id;
    } else {
        newMsg.to_id.user_id = encryptedChat.participant_id;
    }
    if (decryptedMessage instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || decryptedMessage instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
        newMsg.date = getConnectionsManager().getCurrentTime();
    } else {
        newMsg.date = 0;
    }
    newMsg.random_id = getSendMessagesHelper().getNextRandomId();
    getUserConfig().saveConfig(false);

    ArrayList<TLRPC.Message> arr = new ArrayList<>();
    arr.add(newMsg);
    getMessagesStorage().putMessages(arr, false, true, true, 0, false);

    return newMsg;
}