#pragma once
// Spec: INV-social 15.5 (routing, priority order) and the redirect parsing of NotificationsView.ViewModel.
#include <optional>
#include <string>
#include "model/Notification.hpp"
#include "model/User.hpp"
#include "screens/PostDestination.hpp"
namespace dp {
struct NotificationRoute {
enum class Kind { Post, Conversation, Web, OwnProfile };
Kind kind = Kind::Post;
PostDestination post;
User user;
std::string url;
};
class NotificationRouting {
public:
// 1 message+actor -> conversation, 2 badge -> own profile, 3 issue -> web, 4 redirect with /posts/<slug> -> post.
static std::optional<NotificationRoute> route(const Notification& notification, const std::string& redirect);
static std::optional<PostDestination> postDestination(const std::string& redirect);
static std::optional<std::string> postSlug(const std::string& url);
// Fragment (comment-, comment_, comment:, comment prefixes), then query (comment, comment_id, commentId,
// comment_uid), then the path segment after "comments".
static std::optional<std::string> commentUid(const std::string& url);
};
} // namespace dp