<p></p>
<p><b>@tomhughes</b> requested changes on this pull request.</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5344#discussion_r1855483571">db/structure.sql</a>:</p>
<pre style='color:#555'>> @@ -9,6 +9,13 @@ SET xmloption = content;
 SET client_min_messages = warning;
 SET row_security = off;
 
+--
+-- Name: public; Type: SCHEMA; Schema: -; Owner: -
+--
+
+-- *not* creating schema, since initdb creates it
+
+
</pre>
<p dir="auto">This block is noise created by the version of <code class="notranslate">pg_dump</code> you're using and has nothing to do with the actual changes in this PR so should be removed.</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5344#discussion_r1855484223">db/migrate/20241030122707_create_note_tags.rb</a>:</p>
<pre style='color:#555'>> @@ -0,0 +1,13 @@
+class CreateNoteTags < ActiveRecord::Migration[7.2]
+  def change
+    # Create a table and primary key
+    create_table :note_tags, :primary_key => [:note_id, :k] do |t|
+      t.column "note_id", :bigint, :null => false
+      t.column "k",  :string, :default => "", :null => false
+      t.column "v",  :string, :default => "", :null => false
+    end
+
+    # Add foreign key without validation
+    add_foreign_key :note_tags, :notes, :column => :note_id, :name => "note_tags_id_fkey", :validate => false
</pre>
<p dir="auto">Would moving this inside the <code class="notranslate">create_table</code> as <code class="notranslate">t.foreign_key</code> avoid the need to create it with validation disabled? Not sure if the strong migrations is clever enough to know that is safe?</p>
<p dir="auto">If not then you can just add a second migration to enable validation as it's safe to do on an empty table.</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5344#discussion_r1855485164">app/assets/javascripts/index/new_note.js</a>:</p>
<pre style='color:#555'>> @@ -50,7 +50,8 @@ OSM.NewNote = function (map) {
       data: {
         lat: location.lat,
         lon: location.lng,
-        text: $(form.text).val()
+        text: $(form.text).val(),
+        tags: "created_by:OpenStreetMaps-Website"
</pre>
<p dir="auto">There is no <code class="notranslate">s</code> on the end of OpenStreetMap ;-) I'm not sure what is the best value for the tag here but it definitely shouldn't have the trailing s.</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5344#discussion_r1855485608">app/controllers/api/notes_controller.rb</a>:</p>
<pre style='color:#555'>> @@ -83,12 +85,30 @@ def create
       lat = OSM.parse_float(params[:lat], OSM::APIBadUserInput, "lat was not a number")
       comment = params[:text]
 
+      # Extract the tags parameter (if it exists)
+      tags = []
+      if params[:tags].present?
+        # Split by commas to get individual key-value pairs
+        pairs = params[:tags].split(",")
+
+        # For each pair in parameters, store it in tags variable
+        pairs.each do |pair|
+          key, value = pair.split(":", 2)
+          tags << { :k => sanitize(key), :v => sanitize(value) } if key && value
+        end
+      end
</pre>
<p dir="auto">Encoding all the tags in a string like this is nasty and creates all sorts of problems if people use colons or commas in tag names or values - colons in particular are historically common in tag names for other object types.</p>
<p dir="auto">I'm not sure what the solution is as this API is unusual in using form parameters rather than an XML or JSON body to create an object.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5344#pullrequestreview-2456745482">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLO7DQ4KOZNU2G6RYPT2CH4LXAVCNFSM6AAAAABSCG2KCWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDINJWG42DKNBYGI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLIWHKGRQYIOFY2LNP32CH4LXA5CNFSM6AAAAABSCG2KCWWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTUSN33AU.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/5344/review/2456745482</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/5344#pullrequestreview-2456745482",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5344#pullrequestreview-2456745482",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>