Don't send posts to social media multiple times

Check if a post has previously been sent to social media, by checking
the value of a `field_sent_to_social_media` field.

This field is hidden on the node add/edit forms, and populated when a
post is sent to social media. Once this happens, it will not be sent to
social media again.

This change also populates the field for all existing posts, so that
they won't be re-sent to social media either.
This commit is contained in:
Oliver Davies 2020-08-12 20:28:19 +01:00
parent 8761f9c4cc
commit 8385d6fef7
10 changed files with 114 additions and 2 deletions

View file

@ -7,6 +7,7 @@ dependencies:
- field.field.node.post.field_excerpt
- field.field.node.post.field_has_tweet
- field.field.node.post.field_images
- field.field.node.post.field_sent_to_social_media
- field.field.node.post.field_series
- field.field.node.post.field_tags
- node.type.post
@ -127,4 +128,5 @@ content:
region: content
settings: { }
third_party_settings: { }
hidden: { }
hidden:
field_sent_to_social_media: true

View file

@ -7,6 +7,7 @@ dependencies:
- field.field.node.post.field_excerpt
- field.field.node.post.field_has_tweet
- field.field.node.post.field_images
- field.field.node.post.field_sent_to_social_media
- field.field.node.post.field_series
- field.field.node.post.field_tags
- node.type.post
@ -25,6 +26,16 @@ content:
settings: { }
third_party_settings: { }
region: content
field_sent_to_social_media:
weight: 3
label: above
settings:
format: default
format_custom_false: ''
format_custom_true: ''
third_party_settings: { }
type: boolean
region: content
field_tags:
weight: 2
label: above

View file

@ -8,6 +8,7 @@ dependencies:
- field.field.node.post.field_excerpt
- field.field.node.post.field_has_tweet
- field.field.node.post.field_images
- field.field.node.post.field_sent_to_social_media
- field.field.node.post.field_series
- field.field.node.post.field_tags
- node.type.post
@ -34,5 +35,6 @@ hidden:
body: true
field_has_tweet: true
field_images: true
field_sent_to_social_media: true
field_series: true
field_tags: true

View file

@ -0,0 +1,23 @@
uuid: 4f639dd0-6634-43ea-89a8-141dfde87059
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_sent_to_social_media
- node.type.post
id: node.post.field_sent_to_social_media
field_name: field_sent_to_social_media
entity_type: node
bundle: post
label: 'Sent to social media'
description: ''
required: false
translatable: false
default_value:
-
value: 0
default_value_callback: ''
settings:
on_label: 'On'
off_label: 'Off'
field_type: boolean

View file

@ -0,0 +1,18 @@
uuid: 2fead662-4d91-4788-b739-8e1a56d236af
langcode: en
status: true
dependencies:
module:
- node
id: node.field_sent_to_social_media
field_name: field_sent_to_social_media
entity_type: node
type: boolean
settings: { }
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false