Skip to content

Conversation

@01zulfi
Copy link
Contributor

@01zulfi 01zulfi commented Nov 24, 2025

No description provided.

@01zulfi 01zulfi force-pushed the monograph/editable-url branch from 4fe5107 to 7e0e5fa Compare November 25, 2025 06:28
@01zulfi 01zulfi changed the title monographs: allow editable URLs monographs: add slug field which regenerates on update Nov 25, 2025
Comment on lines +238 to +246
if (!string.IsNullOrEmpty(monograph?.Slug))
{
return NotFound(new
{
error = "invalid_id",
error_description = $"No such monograph found."
});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still contemplating if we need to add this check. On one hand, I think it makes sense to restrict fetching monograph by id if the slug exists. On another hand, if a user's client app is a bit behind (i.e. doesn't have the slug property yet), they'll be shown the monograph link with the id which will be a 404 causing confusion

@01zulfi 01zulfi force-pushed the monograph/editable-url branch from 7e0e5fa to 5717b67 Compare November 26, 2025 07:06
return Ok();
}

[HttpGet("{id}/publish-url")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can combine analytics and publish-url endpoints into one?

Comment on lines -278 to +292
var userMonographs = await Repositories.Monographs.Collection.Find(filter).Project((m) => new MonographMetadata
var userMonographs = await Repositories.Monographs.Collection.Find(filter).ToListAsync();
var userMonographMetadatas = userMonographs.Select((m) => new MonographMetadata
{
DatePublished = m.DatePublished,
Deleted = m.Deleted,
Password = m.Password,
SelfDestruct = m.SelfDestruct,
Title = m.Title,
PublishUrl = m.ConstructPublishUrl(),
ItemId = m.ItemId ?? m.Id.ToString(),
ViewCount = m.ViewCount
}).ToListAsync();
}).ToList();

if (userMonographs.Count > 0 && !await Clients.Caller.SendMonographs(userMonographs).WaitAsync(TimeSpan.FromMinutes(10)))
if (userMonographMetadatas.Count > 0 && !await Clients.Caller.SendMonographs(userMonographMetadatas).WaitAsync(TimeSpan.FromMinutes(10)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to use m.ConstructPublishUrl method inside MongoDB's Project. It would throw expression not supported exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant