divan/RMuseum/Models/Ganjoor
Ehsan Mohandesi cb7b1b03a3 Replace Spotify search with a validated music link box
The Spotify Web API integration stopped working, leaving /spotify unable to
suggest songs at all. Replace the artist/album/track search flow with a single
box where the user pastes a link to the track on a music service.

Links are checked against a hardcoded allow-list of legal streaming and store
domains so links to ripped audio cannot be submitted. The check lives in the
service layer, not just the page: any authenticated user can POST to
/api/ganjoor/song directly and bypass the UI. Hosts are matched against the
full host or a dot-prefixed suffix, so look-alikes such as
open.spotify.com.evil.com are rejected; https is required, and userinfo and
non-default ports are refused. Accepted URLs are canonicalised - https,
lowercased host, tracking parameters stripped - so the same track always yields
the same stored URL and duplicate detection actually works.

Links are stored under one new type, PoemMusicTrackType.MusicUrl, with the
platform derived from the host at render time. That needs no migration or
backfill, and supporting another service later needs no new enum value. The
duplicate check no longer keys on TrackType, which closes a gap where the same
URL could be resubmitted as a different type. Several links per poem remain
allowed; only an identical URL for the same poem is refused.

The Spotify search page and its OAuth plumbing are kept and simply redirect to
/musiclink while the existing SpotifyWorking flag is false, so the old flow can
be restored if that API ever works again.

Track URLs are no longer written through Html.Raw into href attributes. They
previously came from the Spotify API; now that they are user supplied, encoding
them prevents stored XSS.

Also fixes two latent bugs in SuggestSong that this flow would have hit: a null
dereference when TrackUrl is empty, and a singer lookup that matched any singer
with an empty Url.
2026-09-13 22:16:18 -05:00
..
PublicExport include couplet sumaries in public data export 2026-09-12 16:06:54 +03:30
SemanticSearch semantic search 2026-09-11 16:45:47 +03:30
ViewModels Replace Spotify search with a validated music link box 2026-09-13 22:16:18 -05:00
CategoryWordCount.cs #444 removing CategoryWordCount.PoetCat 2024-06-26 12:11:06 +03:30
CategoryWordCountSummary.cs #444 FillCategoryWordCountSummaries 2024-06-26 12:20:15 +03:30
CorrectionReviewResult.cs moderation new option 2026-09-13 13:39:48 +03:30
DigitalSource.cs #422 UpdateDigitalSourcesStats 2024-06-17 13:42:58 +03:30
DiscoverQuotedQueueItem.cs #418 DiscoverQuotedQueueItem model 2023-12-22 18:08:23 +03:30
GanjoorCachedRelatedPoem.cs #241 adding PoetId to GanjoorCachedRelatedPoem and changing index on the table 2021-11-16 19:38:02 +03:30
GanjoorCachedRelatedSection.cs docs: #306 updating poem sections when updating page 2022-04-17 19:27:24 +04:30
GanjoorCat.cs #467 GanjoorCatCorrection model 2025-02-14 11:19:05 +03:30
GanjoorCatCorrection.cs #467 adding page id 2025-03-26 14:28:57 +03:30
GanjoorCatType.cs docs: #292 saviing category specific fields in modification api 2022-03-16 22:16:44 +03:30
GanjoorCentury.cs #224 renaming tables 2021-10-21 20:32:46 +03:30
GanjoorCenturyPoet.cs #224 renaming tables 2021-10-21 20:32:46 +03:30
GanjoorComment.cs #495 GanjoorComment + new fields 2026-07-21 21:19:22 +03:30
GanjoorCommentAbuseReport.cs #80 adding GanjoorCommentAbuseReport model 2021-03-02 19:32:10 +03:30
GanjoorCommentReaction.cs #495 RateCommentAsync 2026-07-22 19:30:16 +03:30
GanjoorCommentSortOrder.cs new sorting option 2026-08-04 20:58:05 +03:30
GanjoorDuplicate.cs docs: #302 GanjoorDuplicate model 2022-03-27 14:09:24 +04:30
GanjoorGeoLocation.cs #454 adding MachineGenerated fields to geo tag related tables 2024-12-12 17:33:33 +03:30
GanjoorHealthCheckError.cs #109 (db migration not added yet) + some compiler warning fixes 2021-04-29 21:48:56 +04:30
GanjoorLanguage.cs docs: #371 move language definitions to database 2023-03-21 11:10:32 +03:30
GanjoorMetre.cs #268 updating GanjoorMetre.VerseCount (deliberately with couplets count) to use in displaying list of metres 2021-12-29 20:37:59 +03:30
GanjoorNumbering.cs #217 improving database model 2021-10-04 14:52:08 +03:30
GanjoorPage.cs docs: #292 adding some more fields to models 2022-03-08 20:46:11 +03:30
GanjoorPageSnapshot.cs #104 page modification method (code not complete and working and a db migration is required which is not yet generated) 2021-04-08 14:23:06 +04:30
GanjoorPageType.cs #88 page navigation for normal pages 2021-03-13 15:01:48 +03:30
GanjoorPoem.cs #445 db migartion 2024-07-21 11:47:58 +03:30
GanjoorPoemCorrection.cs docs: #373 completing some view models 2023-03-30 18:01:40 +03:30
GanjoorPoemFormat.cs docs: #373 updating some view models 2023-03-30 17:46:13 +03:30
GanjoorPoemProbableMetre.cs docs: #324 changes probable meters to support poem sections 2022-05-23 12:59:10 +04:30
GanjoorPoemSection.cs stats for poems couplet counts in categories 2025-01-28 11:20:44 +03:30
GanjoorPoemSectionCorrection.cs docs: #373 fields for protecting users's privacy while editing public records 2023-03-27 15:54:40 +03:30
GanjoorPoemTranslation.cs #203 db structure fix 2021-09-16 09:52:45 +04:30
GanjoorPoet.cs #445 db migartion 2024-07-21 11:47:58 +03:30
GanjoorPoetSuggestedPicture.cs #478 add publication date for poet spec lines and pictures 2025-03-28 16:01:30 +03:30
GanjoorPoetSuggestedSpecLine.cs #478 add publication date for poet spec lines and pictures 2025-03-28 16:01:30 +03:30
GanjoorQuotedPoem.cs #420 extending GanjoorQuotedPoem model 2024-01-05 08:45:58 +03:30
GanjoorRelatedPerson.cs #454 adding MachineGenerated fields to geo tag related tables 2024-12-12 17:33:33 +03:30
GanjoorSiteBanner.cs #106 add site banner method 2021-04-19 18:39:20 +04:30
GanjoorTajikCat.cs #467 GanjoorCatCorrection model 2025-02-14 11:19:05 +03:30
GanjoorTajikPage.cs #445 GanjoorTajikPage 2024-07-21 15:03:02 +03:30
GanjoorTajikPoem.cs #445 tajik search 2024-08-20 18:01:26 +03:30
GanjoorTajikPoet.cs #467 GanjoorCatCorrection model 2025-02-14 11:19:05 +03:30
GanjoorTajikVerse.cs #445 tajik poem services 2024-07-21 10:43:19 +03:30
GanjoorTOC.cs docs: #316 adding not sorted option to fix problem with alphabetic TOCs with different alphabetic orders 2022-05-04 21:28:22 +04:30
GanjoorUserBookmark.cs docs: #277 adding the db migration 2022-01-20 12:06:19 +03:30
GanjoorUserPoemVisit.cs #493 GanjoorUserPoemVisit += Counter 2026-06-26 19:01:23 +03:30
GanjoorVerse.cs #445 db migartion 2024-07-21 11:47:58 +03:30
GanjoorVerseNumber.cs #217 improving database model 2021-10-04 14:52:08 +03:30
GanjoorVerseTranslation.cs #203 changing db structure 2021-09-12 18:27:35 +04:30
GanjoorVerseVOrderText.cs docs: #373 new fields 2023-03-27 15:00:58 +03:30
PoemGeoDateTag.cs #454 adding MachineGenerated fields to geo tag related tables 2024-12-12 17:33:33 +03:30
PoemMusicTrack.cs #100 adding SongOrder field 2021-03-25 11:42:03 +04:30
PoemMusicTrackType.cs Replace Spotify search with a validated music link box 2026-09-13 22:16:18 -05:00
PoemSectionType.cs docs: #306 adding poem sections to GanjoorPoemCompleteViewModel 2022-04-07 10:41:02 +04:30
UpdatingRelSectsLog.cs docs: #322 preventing parallel same data update-related-sections (model+code/ no db migrations) 2022-05-20 11:01:10 +04:30
VersePoemSectionType.cs docs: #306 adding HtmlText and PlainText to GanjoorPoemSection model and filling and using them 2022-04-10 20:52:54 +04:30
VersePosition.cs #219 support for VersePosition.Comment 2021-10-06 13:00:48 +03:30
VersePositionHelper.cs docs: #327 adding a helper class to enumerate VersePosition enum values and convert them to Persian string 2022-05-29 09:42:33 +04:30