List of usage examples for twitter4j DirectMessage getId
long getId();
From source file:org.getlantern.firetweet.model.ParcelableDirectMessage.java
License:Open Source License
public ParcelableDirectMessage(final DirectMessage message, final long account_id, final boolean is_outgoing) { this.account_id = account_id; this.is_outgoing = is_outgoing; final User sender = message.getSender(), recipient = message.getRecipient(); final String sender_profile_image_url = sender != null ? sender.getProfileImageUrlHttps() : null; final String recipient_profile_image_url = recipient != null ? recipient.getProfileImageUrlHttps() : null; id = message.getId(); timestamp = getTime(message.getCreatedAt()); sender_id = sender != null ? sender.getId() : -1; recipient_id = recipient != null ? recipient.getId() : -1; text_html = TwitterContentUtils.formatDirectMessageText(message); text_plain = message.getText();//from w w w .ja v a 2s .co m sender_name = sender != null ? sender.getName() : null; recipient_name = recipient != null ? recipient.getName() : null; sender_screen_name = sender != null ? sender.getScreenName() : null; recipient_screen_name = recipient != null ? recipient.getScreenName() : null; this.sender_profile_image_url = sender_profile_image_url; this.recipient_profile_image_url = recipient_profile_image_url; text_unescaped = toPlainText(text_html); media = ParcelableMedia.fromEntities(message); }
From source file:org.getlantern.firetweet.util.ContentValuesCreator.java
License:Open Source License
public static ContentValues createDirectMessage(final DirectMessage message, final long accountId, final boolean isOutgoing) { if (message == null) return null; final ContentValues values = new ContentValues(); final User sender = message.getSender(), recipient = message.getRecipient(); if (sender == null || recipient == null) return null; final String sender_profile_image_url = sender.getProfileImageUrlHttps(); final String recipient_profile_image_url = recipient.getProfileImageUrlHttps(); values.put(DirectMessages.ACCOUNT_ID, accountId); values.put(DirectMessages.MESSAGE_ID, message.getId()); values.put(DirectMessages.MESSAGE_TIMESTAMP, message.getCreatedAt().getTime()); values.put(DirectMessages.SENDER_ID, sender.getId()); values.put(DirectMessages.RECIPIENT_ID, recipient.getId()); if (isOutgoing) { values.put(DirectMessages.CONVERSATION_ID, recipient.getId()); } else {//from ww w . ja v a 2 s. c om values.put(DirectMessages.CONVERSATION_ID, sender.getId()); } final String text_html = TwitterContentUtils.formatDirectMessageText(message); values.put(DirectMessages.TEXT_HTML, text_html); values.put(DirectMessages.TEXT_PLAIN, message.getText()); values.put(DirectMessages.TEXT_UNESCAPED, toPlainText(text_html)); values.put(DirectMessages.IS_OUTGOING, isOutgoing); values.put(DirectMessages.SENDER_NAME, sender.getName()); values.put(DirectMessages.SENDER_SCREEN_NAME, sender.getScreenName()); values.put(DirectMessages.RECIPIENT_NAME, recipient.getName()); values.put(DirectMessages.RECIPIENT_SCREEN_NAME, recipient.getScreenName()); values.put(DirectMessages.SENDER_PROFILE_IMAGE_URL, sender_profile_image_url); values.put(DirectMessages.RECIPIENT_PROFILE_IMAGE_URL, recipient_profile_image_url); final ParcelableMedia[] mediaArray = ParcelableMedia.fromEntities(message); if (mediaArray != null) { values.put(DirectMessages.MEDIA_LIST, SimpleValueSerializer.toSerializedString(mediaArray)); } return values; }
From source file:org.mariotaku.twidere.util.ContentValuesCreator.java
License:Open Source License
public static ContentValues createDirectMessage(final DirectMessage message, final long accountId, final boolean isOutgoing) { if (message == null) return null; final ContentValues values = new ContentValues(); final User sender = message.getSender(), recipient = message.getRecipient(); if (sender == null || recipient == null) return null; final String sender_profile_image_url = sender.getProfileImageUrlHttps(); final String recipient_profile_image_url = recipient.getProfileImageUrlHttps(); values.put(DirectMessages.ACCOUNT_ID, accountId); values.put(DirectMessages.MESSAGE_ID, message.getId()); values.put(DirectMessages.MESSAGE_TIMESTAMP, message.getCreatedAt().getTime()); values.put(DirectMessages.SENDER_ID, sender.getId()); values.put(DirectMessages.RECIPIENT_ID, recipient.getId()); if (isOutgoing) { values.put(DirectMessages.CONVERSATION_ID, recipient.getId()); } else {// w ww. java 2 s. co m values.put(DirectMessages.CONVERSATION_ID, sender.getId()); } final String text_html = TwitterContentUtils.formatDirectMessageText(message); values.put(DirectMessages.TEXT_HTML, text_html); values.put(DirectMessages.TEXT_PLAIN, message.getText()); values.put(DirectMessages.TEXT_UNESCAPED, toPlainText(text_html)); values.put(DirectMessages.IS_OUTGOING, isOutgoing); values.put(DirectMessages.SENDER_NAME, sender.getName()); values.put(DirectMessages.SENDER_SCREEN_NAME, sender.getScreenName()); values.put(DirectMessages.RECIPIENT_NAME, recipient.getName()); values.put(DirectMessages.RECIPIENT_SCREEN_NAME, recipient.getScreenName()); values.put(DirectMessages.SENDER_PROFILE_IMAGE_URL, sender_profile_image_url); values.put(DirectMessages.RECIPIENT_PROFILE_IMAGE_URL, recipient_profile_image_url); final ParcelableMedia[] mediaArray = ParcelableMedia.fromEntities(message); if (mediaArray != null) { try { values.put(DirectMessages.MEDIA_JSON, LoganSquare.serialize(Arrays.asList(mediaArray), ParcelableMedia.class)); } catch (IOException ignored) { } } return values; }
From source file:org.mariotaku.twidere.util.Utils.java
License:Open Source License
public static boolean truncateMessages(final List<DirectMessage> in, final List<DirectMessage> out, final long sinceId) { if (in == null) return false; for (final DirectMessage message : in) { if (sinceId > 0 && message.getId() <= sinceId) { continue; }/*from w w w . j a va 2s .c o m*/ out.add(message); } return in.size() != out.size(); }
From source file:org.nsoft.openbus.model.Mensagem.java
License:Open Source License
public static Mensagem createFromDirectMensagem(DirectMessage dm) { try {// w w w. j a v a2s .c o m Mensagem mensagem = new Mensagem(); mensagem.setAction(OpenTwitterStatusAction.getInstance()); mensagem.idMensagem = Long.toString(dm.getId()); mensagem.nome_usuario = dm.getSender().getName(); mensagem.mensagem = dm.getText(); // mensagem.imagePath = dm.getSender().getProfileImageURL(); mensagem.data = dm.getCreatedAt(); mensagem.idUser = dm.getSender().getId(); mensagem.tipo = TIPO_STATUS; return mensagem; } catch (Exception e) { return null; } }
From source file:org.opennms.netmgt.notifd.MicroblogDMNotificationStrategy.java
License:Open Source License
/** {@inheritDoc} */ @Override/* w w w.j a v a 2 s .co m*/ public int send(List<Argument> arguments) { Twitter svc = buildUblogService(arguments); String destUser = findDestName(arguments); DirectMessage response; if (destUser == null || "".equals(destUser)) { LOG.error( "Cannot send a microblog DM notice to a user with no microblog username set. Either set a microblog username for this OpenNMS user or use the MicroblogUpdateNotificationStrategy instead."); return 1; } // In case the user tried to be helpful, avoid a double @@ if (destUser.startsWith("@")) destUser = destUser.substring(1); String fullMessage = buildMessageBody(arguments); LOG.debug( "Dispatching microblog DM notification at base URL '{}' with destination user '{}' and message '{}'", svc.getConfiguration().getClientURL(), destUser, fullMessage); try { response = svc.sendDirectMessage(destUser, fullMessage); } catch (TwitterException e) { LOG.error("Microblog notification failed at service URL '{}' to destination user '{}'", svc.getConfiguration().getClientURL(), destUser, e); return 1; } LOG.info("Microblog DM notification succeeded: DM sent with ID {}", response.getId()); return 0; }
From source file:org.sociotech.communitymashup.source.twitter.TwitterSourceService.java
License:Open Source License
/** * Creates a content for the given message, adds it to the data set and sets * the author./*from ww w . j ava 2 s.c o m*/ * * @param author * Person corresponding to the twitter user which authored the * message * @param author * Person corresponding to the twitter user which received the * message * @param directMessage * The twitter status * @return The Content created from the status, null in error case. */ private Content createContentFromTwitterDirectMessage(Person author, Person receipient, DirectMessage directMessage) { if (directMessage == null) { return null; } String messageText = directMessage.getText(); if (messageText == null || messageText.isEmpty()) { return null; } String ident = directMessage.getId() + ""; if (this.getContentWithSourceIdent(ident) != null) { // message already created return null; } Content message = factory.createContent(); message.setStringValue(messageText); message.setName(createTitleFromTwitterText(messageText)); message.metaTag(TwitterTags.TWITTER); message = (Content) this.add(message, ident); if (message == null) { return null; } if (author != null) { message.setAuthor(author); } message.setCreated(directMessage.getCreatedAt()); if (receipient != null) { // set receiver as contributor message.getContributors().add(receipient); } message.metaTag(TwitterTags.DIRECT_MESSAGE); return message; }
From source file:org.springframework.integration.twitter.InboundDMStatusEndpoint.java
License:Apache License
@Override protected void markLastStatusId(DirectMessage dm) { this.markerId = dm.getId(); }
From source file:org.tweetalib.android.model.TwitterDirectMessage.java
License:Apache License
public TwitterDirectMessage(DirectMessage message, User otherUser) { mId = message.getId(); mText = message.getText();//from w w w .ja va 2s .c o m mStatusFullMarkup = TwitterUtil.getStatusMarkup(mText, message.getMediaEntities(), message.getURLEntities()); mTextSpanned = URLSpanNoUnderline .stripUnderlines(Html.fromHtml(mStatusFullMarkup.replace("\n", "<br/>") + " ")); mCreatedAt = message.getCreatedAt(); mOtherUserId = otherUser.getId(); mRecipientUserId = message.getRecipientId(); mOtherUserScreenName = otherUser.getScreenName(); mOtherUserName = otherUser.getName(); mOtherUserProfileImageOriginalUrl = otherUser.getOriginalProfileImageURL(); mOtherUserProfileImageMiniUrl = otherUser.getMiniProfileImageURL(); mOtherUserProfileImageNormalUrl = otherUser.getProfileImageURL(); mOtherUserProfileImageBiggerUrl = otherUser.getBiggerProfileImageURL(); TwitterUser sender = new TwitterUser(message.getSender()); mSenderProfileImageOriginalUrl = sender.getProfileImageUrlOriginal(); mSenderProfileImageMiniUrl = sender.getProfileImageUrlMini(); mSenderProfileImageNormalUrl = sender.getProfileImageUrlNormal(); mSenderProfileImageBiggerUrl = sender.getProfileImageUrlBigger(); mMessageType = mRecipientUserId == mOtherUserId ? MessageType.SENT : MessageType.RECEIVED; }
From source file:twitbak.DirectMessageBak.java
License:Open Source License
/** * Adds a DirectMessage to statusArray as a JSONObject. * /*ww w. jav a 2 s. com*/ * @param dm * @throws TwitterException * @throws JSONException */ private void dmToJson(DirectMessage dm) throws TwitterException, JSONException { JSONObject result = new JSONObject(); result.put("Created At", dm.getCreatedAt().toString()); result.put("ID", dm.getId()); result.put("Text", dm.getText()); result.put("Sender ID", dm.getSenderId()); result.put("Sender", dm.getSender().getScreenName()); result.put("Sender Name", dm.getSender().getName()); statusArray.put(result); }