Formatting content for Dialog List and Notifications

@param senderId    sender of message (used in service messages)
@param contentType type of content
@param text        text of message
@param relatedUid  optional related uid
@return formatted content
10533
@ObjectiveCName("formatContentTextWithSenderId:withContentType:withText:withRelatedUid:withIsChannel:")
    public String formatContentText(int senderId, ContentType contentType, String text, int relatedUid,
                                    boolean isChannel) {

        String groupKey = isChannel ? "channels" : "groups";

        switch (contentType) {
            case TEXT:
                return text;
            case DOCUMENT:
                if (text == null || text.length() == 0) {
                    return get("content.document");
                }
                return text;// File name
            case DOCUMENT_PHOTO:
                return get("content.photo");
            case DOCUMENT_VIDEO:
                return get("content.video");
            case DOCUMENT_AUDIO:
                return get("content.audio");
            case CONTACT:
                return get("content.contact");
            case LOCATION:
                return get("content.location");
            case STICKER:
                if (text != null && !"".equals(text)) {
                    return text + " " + get("content.sticker");
                } else {
                    return get("content.sticker");
                }
            case SERVICE:
                return text;// Should be service message
            case SERVICE_REGISTERED:
                return getTemplateNamed(senderId, "content.service.registered.compact")
                        .replace("{app_name}", getAppName());
            case SERVICE_CREATED:
                return getTemplateNamed(senderId, "content.service." + groupKey + ".created");
            case SERVICE_ADD:
                return getTemplateNamed(senderId, "content.service." + groupKey + ".invited")
                        .replace("{name_added}", getSubjectName(relatedUid));
            case SERVICE_LEAVE:
                return getTemplateNamed(senderId, "content.service." + groupKey + ".left");
            case SERVICE_KICK:
                return getTemplateNamed(senderId, "content.service." + groupKey + ".kicked")
                        .replace("{name_kicked}", getSubjectName(relatedUid));
            case SERVICE_AVATAR:
                return getTemplateNamed(senderId, "content.service." + groupKey + ".avatar_changed");
            case SERVICE_AVATAR_REMOVED:
                return getTemplateNamed(senderId, "content.service." + groupKey + ".avatar_removed");
            case SERVICE_TITLE:
                return getTemplateNamed(senderId, "content.service." + groupKey + ".title_changed.compact");
            case SERVICE_TOPIC:
                return getTemplateNamed(senderId, "content.service." + groupKey + ".topic_changed.compact");
            case SERVICE_ABOUT:
                return getTemplateNamed(senderId, "content.service." + groupKey + ".about_changed.compact");
            case SERVICE_JOINED:
                return getTemplateNamed(senderId, "content.service." + groupKey + ".joined");
            case SERVICE_CALL_ENDED:
                return get("content.service.calls.ended");
            case SERVICE_CALL_MISSED:
                return get("content.service.calls.missed");
            case NONE:
                return "";
            default:
            case UNKNOWN_CONTENT:
                return get("content.unsupported");
        }
    }
194916
public static MessageProtocol fromContentTypeHeader(Optional<String> contentType) {
        return contentType.map(ct -> {
            String[] parts = ct.split(";");
            String justContentType = parts[0];
            Optional<String> charset = Optional.empty();
            for (int i = 1; i < parts.length; i++) {
                String toTest = parts[i].trim();
                if (toTest.startsWith("charset=")) {
                    charset = Optional.of(toTest.split("=", 2)[1]);
                    break;
                }
            }
            return new MessageProtocol(Optional.of(justContentType), charset, Optional.empty());
        }).orElse(new MessageProtocol());
    }
562940
function(messageContent, threadId) {
                /**
                 * + ParticipantVO                   {object}
                 *    - id                           {long}
                 *    - coreUserId                   {long}
                 *    - threadId                     {long}
                 *    - sendEnable                   {boolean}
                 *    - receiveEnable                {boolean}
                 *    - firstName                    {string}
                 *    - lastName                     {string}
                 *    - name                         {string}
                 *    - cellphoneNumber              {string}
                 *    - email                        {string}
                 *    - myFriend                     {boolean}
                 *    - online                       {boolean}
                 *    - blocked                      {boolean}
                 *    - notSeenDuration              {long}
                 *    - contactId                    {long}
                 *    - image                        {string}
                 *    - contactName                  {string}
                 *    - contactFirstName             {string}
                 *    - contactLastName              {string}
                 */

                var participant = {
                    id: messageContent.id,
                    coreUserId: messageContent.coreUserId,
                    threadId: threadId,
                    sendEnable: messageContent.sendEnable,
                    receiveEnable: messageContent.receiveEnable,
                    firstName: messageContent.firstName,
                    lastName: messageContent.lastName,
                    name: messageContent.name,
                    cellphoneNumber: messageContent.cellphoneNumber,
                    email: messageContent.email,
                    myFriend: messageContent.myFriend,
                    online: messageContent.online,
                    blocked: messageContent.blocked,
                    notSeenDuration: messageContent.notSeenDuration,
                    contactId: messageContent.contactId,
                    image: messageContent.image,
                    contactName: messageContent.contactName,
                    contactFirstName: messageContent.contactFirstName,
                    contactLastName: messageContent.contactLastName
                };

                return participant;
            }
1247947
public function getRecipientsWhoFollowContent(array $related_entity, array $data) {
    $recipients = [];

    $storage = \Drupal::entityTypeManager()->getStorage('flagging');
    $flaggings = $storage->loadByProperties([
      'flag_id' => 'follow_content',
      'entity_type' => $related_entity['target_type'],
      'entity_id' => $related_entity['target_id'],
    ]);

    // We don't send notifications to users about their own comments.
    $original_related_object = $data['related_object'][0];
    $storage = \Drupal::entityTypeManager()
      ->getStorage($original_related_object['target_type']);
    $original_related_entity = $storage->load($original_related_object['target_id']);

    foreach ($flaggings as $flagging) {
      $recipient = $flagging->getOwner();
      if ($recipient->id() != $original_related_entity->getOwnerId()) {
        if ($original_related_entity->access('view', $recipient)) {
          $recipients[] = [
            'target_type' => 'user',
            'target_id' => $recipient->id(),
          ];
        }
      }
    }

    return $recipients;
  }
782886
def __make_message(self, topic, content):
        
        return {"uid": str(uuid.uuid4()).replace('-', '').upper(),
                "topic": topic,
                "content": content}
852642
def send_group_text(self, sender, receiver, content):
        
        return self.send_text(sender, 'group', receiver, content)
580698
@ObjectiveCName("formatNotificationText:")
    public String formatNotificationText(Notification pendingNotification) {
        return formatContentText(pendingNotification.getSender(),
                pendingNotification.getContentDescription().getContentType(),
                pendingNotification.getContentDescription().getText(),
                pendingNotification.getContentDescription().getRelatedUser(),
                pendingNotification.isChannel());
    }
930115
public void setMessageText(SendableTextMessage.SendableTextMessageBuilder messageBuilder) {
        SendableTextMessage message = messageBuilder.build();
        baseMessage.getBotInstance().editMessageText(baseMessage, message.getMessage(), message.getParseMode(),
                message.isDisableWebPagePreview(), toKeyboard());
    }
939181
public void xmlWriteOn(FormattedWriter writer) throws IOException
   {
     writer.newLine();
     writer.taggedValue("MEUuid", messagingEngineUuid);
     writer.newLine();
     writer.taggedValue("toBeDeleted", toBeDeleted);
   }
135872
def send_message(self, id_service, content):
        """"""
        if not content:
            return
        with self._lock:
            try:
                message = "Message: %s to %s" % (content, id_service)
                self.write_message(message)
                self.stream.flush()  # flush after each message
                return "message_id"
            except Exception:
                if not self.fail_silently:
                    raise
892784
public List<WebhookDeliveryLiteDto> selectOrderedByComponentUuid(DbSession dbSession, String componentUuid, int offset, int limit) {
    return mapper(dbSession).selectOrderedByComponentUuid(componentUuid, new RowBounds(offset, limit));
  }
1066472
public MessageProtocol withContentType(String contentType) {
        return new MessageProtocol(Optional.ofNullable(contentType), charset, version);
    }
116861
public void sendMessageToAgents(String[] agent_name, String msgtype,
            Object message_content, Connector connector) {
        HashMap<String, Object> hm = new HashMap<String, Object>();
        hm.put("performative", msgtype);
        hm.put(SFipa.CONTENT, message_content);
        IComponentIdentifier[] ici = new IComponentIdentifier[agent_name.length];
        for (int i = 0; i < agent_name.length; i++) {
            ici[i] = (IComponentIdentifier) connector.getAgentID(agent_name[i]);
        }
        ((IMessageService) connector.getMessageService()).deliverMessage(hm,
                "fipa", ici);
    }
1300674
public final B contentType(CharSequence contentType) {
        requireNonNull(contentType, "contentType");
        autoDetectedContentType(false);
        return setHeader(HttpHeaderNames.CONTENT_TYPE, contentType);
    }
789635
public static MimeBodyPart newHtmlAttachmentBodyPart( URL contentUrl, String contentId )
    throws MessagingException
  {
    MimeBodyPart mimeBodyPart = new MimeBodyPart();
    mimeBodyPart.setDataHandler(new DataHandler(contentUrl));
    if( contentId != null ) {
      mimeBodyPart.setHeader("Content-ID", contentId);
    }
    return mimeBodyPart;
  }
131778
function sendTextMessage(recipientId, messageText) {
    var messageData = {
        recipient: {
            id: recipientId
        },
        message: {
            text: messageText
        }
    };
    callSendAPI(messageData);
}
545520
function buildMessageHTML(messageText, messageSenderId, messageDateSent, attachmentFileId, messageId) {
    var messageAttach;

    if (attachmentFileId) {
        messageAttach = '<img src="' + QB.content.privateUrl(attachmentFileId) + '" alt="attachment" class="attachments img-responsive" />';
    }

    var delivered = '<img class="icon-small" src="images/delivered.jpg" alt="" id="delivered_' + messageId + '">';
    var read = '<img class="icon-small" src="images/read.jpg" alt="" id="read_' + messageId + '">';

    var messageTextHtml = messageText;
    if (messageAttach) {
        messageTextHtml = messageAttach;
    }

    var messageHtml =
        '<div class="list-group-item" id="' + messageId + '">' +
        '<time datetime="' + messageDateSent + '" class="pull-right">' +
        jQuery.timeago(messageDateSent) +
        '</time>' +

        '<h4 class="list-group-item-heading">' + messageSenderId + '</h4>' +
        '<p class="list-group-item-text">' +
        messageTextHtml +
        '</p>' +
        delivered + read +
        '</div>';
    return messageHtml;
}