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

The following examples show how to use org.telegram.tgnet.TLRPC#TL_inputPeerUser . 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: ImageLocation.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public static ImageLocation getForUser(TLRPC.User user, boolean big) {
    if (user == null || user.access_hash == 0 || user.photo == null) {
        return null;
    }
    TLRPC.FileLocation fileLocation = big ? user.photo.photo_big : user.photo.photo_small;
    if (fileLocation == null) {
        return null;
    }
    TLRPC.TL_inputPeerUser inputPeer = new TLRPC.TL_inputPeerUser();
    inputPeer.user_id = user.id;
    inputPeer.access_hash = user.access_hash;
    int dc_id;
    if (user.photo.dc_id != 0) {
        dc_id = user.photo.dc_id;
    } else {
        dc_id = fileLocation.dc_id;
    }
    return getForPhoto(fileLocation, 0, null, null, inputPeer, big, dc_id, null, null);
}
 
Example 2
Source File: ImageLocation.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public static ImageLocation getForUser(TLRPC.User user, boolean big) {
    if (user == null || user.access_hash == 0 || user.photo == null) {
        return null;
    }
    TLRPC.FileLocation fileLocation = big ? user.photo.photo_big : user.photo.photo_small;
    if (fileLocation == null) {
        return null;
    }
    TLRPC.TL_inputPeerUser inputPeer = new TLRPC.TL_inputPeerUser();
    inputPeer.user_id = user.id;
    inputPeer.access_hash = user.access_hash;
    int dc_id;
    if (user.photo.dc_id != 0) {
        dc_id = user.photo.dc_id;
    } else {
        dc_id = fileLocation.dc_id;
    }
    return getForPhoto(fileLocation, 0, null, null, inputPeer, big, dc_id, null, null);
}
 
Example 3
Source File: FileRefController.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private boolean getPeerReferenceReplacement(TLRPC.User user, TLRPC.Chat chat, boolean big, TLRPC.InputFileLocation location, TLRPC.InputFileLocation[] replacement, boolean[] needReplacement) {
    if (needReplacement != null && needReplacement[0]) {
        replacement[0] = new TLRPC.TL_inputPeerPhotoFileLocation();
        replacement[0].id = location.volume_id;
        replacement[0].volume_id = location.volume_id;
        replacement[0].local_id = location.local_id;
        replacement[0].big = big;
        TLRPC.InputPeer peer;
        if (user != null) {
            TLRPC.TL_inputPeerUser inputPeerUser = new TLRPC.TL_inputPeerUser();
            inputPeerUser.user_id = user.id;
            inputPeerUser.access_hash = user.access_hash;
            peer = inputPeerUser;
        } else {
            if (ChatObject.isChannel(chat)) {
                TLRPC.TL_inputPeerChat inputPeerChat = new TLRPC.TL_inputPeerChat();
                inputPeerChat.chat_id = chat.id;
                peer = inputPeerChat;
            } else {
                TLRPC.TL_inputPeerChannel inputPeerChannel = new TLRPC.TL_inputPeerChannel();
                inputPeerChannel.channel_id = chat.id;
                inputPeerChannel.access_hash = chat.access_hash;
                peer = inputPeerChannel;
            }
        }
        replacement[0].peer = peer;
        return true;
    }
    return false;
}
 
Example 4
Source File: FileRefController.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private boolean getPeerReferenceReplacement(TLRPC.User user, TLRPC.Chat chat, boolean big, TLRPC.InputFileLocation location, TLRPC.InputFileLocation[] replacement, boolean[] needReplacement) {
    if (needReplacement != null && needReplacement[0]) {
        replacement[0] = new TLRPC.TL_inputPeerPhotoFileLocation();
        replacement[0].id = location.volume_id;
        replacement[0].volume_id = location.volume_id;
        replacement[0].local_id = location.local_id;
        replacement[0].big = big;
        TLRPC.InputPeer peer;
        if (user != null) {
            TLRPC.TL_inputPeerUser inputPeerUser = new TLRPC.TL_inputPeerUser();
            inputPeerUser.user_id = user.id;
            inputPeerUser.access_hash = user.access_hash;
            peer = inputPeerUser;
        } else {
            if (ChatObject.isChannel(chat)) {
                TLRPC.TL_inputPeerChat inputPeerChat = new TLRPC.TL_inputPeerChat();
                inputPeerChat.chat_id = chat.id;
                peer = inputPeerChat;
            } else {
                TLRPC.TL_inputPeerChannel inputPeerChannel = new TLRPC.TL_inputPeerChannel();
                inputPeerChannel.channel_id = chat.id;
                inputPeerChannel.access_hash = chat.access_hash;
                peer = inputPeerChannel;
            }
        }
        replacement[0].peer = peer;
        return true;
    }
    return false;
}