How to store message content in a webservice

I am building a service responsible for sending email/sms communications. The service receives a request that contains information necessary to build an email/sms template and the recipient information of where to send it.

Example CURL request:

    curl -X POST \   http://service.local/api/finance/payment-reminder \   -H 'Postman-Token: ec32d436-8eef-4660-8424-600bfca6a3fb' \   -H 'X-API-KEY: secret' \   -H 'cache-control: no-cache' \   -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \   -F method=email \   -F name=dave \   -F email=dave@dave.com \   -F amount=100 \   -F due_date=now \   -F phone_number=8957598696 

Now from here I load the relevant class, send the template via the specified method to the recipient.

From here I need to persist the information I have sent to the customer in order to be able to show consumers of the system what communications have been sent to any given customer.

Thinking about it I have two options:

  1. I can store the request data and the class path used to generate the template and rebuild it if required.

The issue with this is the template may very well be changed in the future. If this happens then my representation of the communication sent is not accurate. Also at some time in the future a template could be moved/deleted and this would cause rebuilding to be impossible.

  1. Store the entire generated output of the template file (HTML for email, text for SMS)

This doesn’t feel ‘clean’ for me as I don’t necessarily like the idea of storing HTML in a database table.

Am I overthinking the storing of HTML and in this scenario it is fine to do. Obviously there will be no need to edit the information once the content has been persisted.

Rewrite or edit your content professionally for $5

Content is a key role for web-business. Well-written content boosts your business and increases your sales. I am a professional writer with great experience, hundreds of words were exposed to my proofreading. I will help you to rewrite your content in the best way. If you need to edit your article, book, review, novel or something else just get in touch with me and I will help you.

by: YanaTranslate
Created: —
Category: Content & Writing
Viewed: 138


Load content from files (and sometimes parse) in Sapper

I am making my first Sapper app and the pages are all in routes. I am now extracting the content into a separate directory and unsure if I’m doing anything right.

Here is an excrept from my directory structure:

content |- index.md |- services.txt |- about    |- index.md    |- technologies.html routes |- index.html |- services.html |- section-[section].json.js |- about    |- index.html    |- technologies.html 

I’ve made JSON interface section-[section].json.js that is used to request content. The content of sectionX can be in file content/sectionX.ext with whatever extension and the content is also parsed through marked if it’s a .md file.

This is how I am loading the content in my routes/services.html:

<script> export default {     preload() {         return this.fetch('section-services.json').then(r => r.json()).then(section => {             return {section};         });     } } </script> 

Nested files are requested using dot notation, i.e. about.technologies could be resolved either to file content/about/technologies.ext or content/about/technologies/index.ext (similar to how sapper resolves URIs to files).

The part that I would like to have reviewed is my routes/section-[section].json.js. This is the file that receives a section name (with slashes replaced by dots) and returns the content, parsed if it’s markdown.

import fs from 'fs' import path from 'path' import marked from 'marked'  function getFileFromDir(file, directory) {     const filesInDir = fs.readdirSync('content/'+directory, {withFileTypes: true})                         .filter(f => f.isFile() && file == path.parse(f.name).name)      if (filesInDir.length)     {         let fileName = 'content/'          if (directory.length)             fileName += directory + '/'          fileName += filesInDir[0].name          return fileName     }      return null }  function getFile(path)  {     path = path.split('.')      // First try to get the named file     let file = getFileFromDir(path[path.length-1], path.slice(0,-1).join('/'))     if (file)         return file      // Assume that path is a directory and look for index     file = getFileFromDir('index', path.join('/'))     if (file)         return file      return null }  export function get(req, res) {     let file = getFile(req.params.section)      if (!file)         return 'Failed to fetch content of section ' + req.params.section      let content = fs.readFileSync(file, 'utf8')      if ('.md' == path.extname(file))         content = marked(content)      res.writeHead(200, {         'Content-Type': 'application/json',         'Cache-Control': `max-age=$  {30 * 60 * 1e3}`     })      content = JSON.stringify({content})      res.end(content) } 

My experience with Node is also fairly limited, any tips appreciated!

Provisioning list which uses content type from content type hub using Site Script SharePoint

We are using Site Script to provision SharePoint resources like lists, libraries, theme, adding site to hub etc. As we are creating lot of lists and libraries we need to use the content types. Our organization has content type hub configured and in site script can we use the content type from content type hub to associate to list/library? Please let me know if anyone has ideas.

Should I implement HTML or Markdown for user-generated content?

Technical considerations:

  • HTML takes 3x the space of Markdown. Even though Markdown would be rendered client-side, it doesn’t quite mean 3x advantage in transmitted payload because gzip would close the gap.
  • HTML will also require textContent returned separately to be indexed for full-text-search, whereas Markdown only uses non-alphanumeric characters which would be omitted by the tokenizer. This means there would be two columns of the body in the database: one with the full HTML for returning, and another with all the tags stripped out for indexing.

UX considerations:

  • IMO markdown is actually quite frustrating to use. A lot of it has to do with it trying to “help” and getting in the way instead. For example, sometimes I see a giant wall of text on Reddit, but viewing the source reveals that OP actually made paragraphs with single line breaks.
  • There is no true WYSIWYG editor for Markdown. I’ve only found editors with a live-preview that call themselves “WYSIWYG-like”, which IMO is too cumbersome to use – exhibit 1, people often edit a post on StackExchange just to fix their Markdown.
  • Related: https://ux.stackexchange.com/questions/15919/is-markdown-friendly-enough-for-non-technical-users

I don’t know if it’d be feasible to convert from one to another later on, so I would like to make the correct decision at the start.

SPO highlighted content on Site Pages library?

I have an SPO Communication site with three custom site columns (all Managed Metadata type) which are all in two separate custom content types. the site columns are mapped to RefinableString00, 01, and 02.

When I add the first content type to a custom list, I can then add a Highlighted Content web part to match items in the list on the managed metadata properties. In Content, my Source is This Site, Type is All, and Document type is Any. In Filter and sort, I Filter a Managed property, search for RefinableString00, and type what the term I want to match is (Contains). Items return from the list as expected but not from Site Pages

I have the second content type added to my Pages library with pages with all three columns populated. I tried targeting the Pages library specifically by setting Source to The page library on this site. However, doesn’t look like managed metadata works with the page properties.

I also tried setting Source to This site and Type to Pages. When I type the refinable to find the managed property, nothing populates.

Any suggestions?

Having no content on product launch

me and my team are facing an issue regarding the release strategy of our application, that is said to impact the User Experience of our first users.

We are building a content-driven app and our business development team argues, that it will be a problem for our beta-users that there is no content at day 0. Just fyi: The content is generated by users messaging other users, who then respond to the initial message. The whole conversation (message a + message b) gets morphed into a public conversation that is visible for all users, that follow the users who had the conversation. So when we launch the app and invite the first users to our platform, there won’t be any public conversations. Visible follower counts on user profiles will be at 0 and the app will overall look kind of empty.

I wonder if you have any guidance for me on how to handle this issue. Should we fake public conversations between fake users, that real users can look at? Should we generate system questions that automatically will be sent to real users arriving on the platform?

Thank you so much in advance.

Changing how Adding Existing Node (from another content type) works

I have a Drupal 8 site with two content types: Recipe and Ingredient, and I have Ingredient as an inline entity form of Recipe form.

So, when I am creating a new Recipe, I get this: enter image description here

My question is: can I change how Add Existing Node works to, instead of a button, it shows a select list with all the current posibilities?

Thank you in advance.

Changing how Adding Existing Node (from another content type) works

I have a Drupal 8 site with two content types: Recipe and Ingredient, and I have Ingredient as an inline entity form of Recipe form.

So, when I am creating a new Recipe, I get this: enter image description here

My question is: can I change how Add Existing Node works to, instead of a button, it shows a select list with all the current posibilities?

Thank you in advance.