Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIP-74 (Portability of Client-side Sorting/Filtering Algorithm) #1268

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions 74.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# NIP-74

## Enhanced Sorting and Filtering for Social Media Posts

`draft` `optional`

## Abstract

This NIP defines `kind:33031`: a standardized JSON configuration for sorting and filtering social media posts. The configuration allows users to customize how posts are displayed based on various parameters and metadata.

## Motivation

Various NOSTR client frameworks need efficient mechanisms to display relevant posts to users. Sorting and filtering based on user preferences, engagement metrics, and content metadata can enhance the user experience by presenting the most pertinent information. This proposal aims to establish a standard format for configuring such sorting and filtering mechanisms, allowing for "portability" of a users algorithmic preferences across existing clients and any future implementations.

## Specification

The configuration is defined using a JSON object with the following structure:

The `.content` of these events should be a JSON-serialized comment of the following structure. It is required but can be an empty string or empty brackets: "{}".

```json
{
"kind": 33031,
"created_at": 1716994345,
"pubkey": "...",
"id": "...",
"content": "<JSON-serialized-string>"
}

unserialized JSON structure:
{
"algorithmName": "EnhancedPostSorter",
"version": "1.0",
"parameters": {
"sortBy": ["timestamp", "engagement", "relevance", "authorInfluence"],
"filters": {
"keywords": ["technology", "science", "sports"],
"language": ["en", "es", "fr"],
"dateRange": {
"startDate": "2023-01-01T00:00:00Z",
"endDate": "2023-12-31T23:59:59Z"
},
"minEngagement": {
"likes": 10,
"retweets": 5,
"comments": 3
},
"userSettings": {
"mutedUsers": ["user123", "user456"],
"blockedUsers": ["user789"],
"preferredAuthors": ["tech_guru", "science_whiz"]
}
},
"metadata": {
"includeRetweets": true,
"includeReplies": false,
"includeMedia": true,
"contentSafety": "safe",
"promotedContent": false
}
}
}

```



## Fields

```
content: Root object for the sorting algorithm configuration.
algorithmName: Name of the sorting algorithm.
version: Version of the sorting algorithm.
parameters: Contains sorting and filtering parameters.
sortBy: An array of criteria used for sorting the posts.
filters: Object containing various filters to refine the posts.
keywords: List of keywords to filter the posts.
language: List of languages to include in the posts.
dateRange: Object specifying the start and end dates for filtering posts.
minEngagement: Minimum engagement metrics (likes, retweets, comments) required for the posts.
userSettings: User-specific settings to further filter the posts.
mutedUsers: List of users whose posts should be muted.
blockedUsers: List of users whose posts should be blocked.
preferredAuthors: List of preferred authors whose posts should be prioritized.
metadata: Additional settings for the posts.
includeRetweets: Boolean indicating whether to include retweets.
includeReplies: Boolean indicating whether to include replies.
includeMedia: Boolean indicating whether to include posts with media.
contentSafety: Level of content safety (safe, moderate, any).
promotedContent: Boolean indicating whether to include promoted content.
```

## Rationale

This standardized configuration allows developers and platforms to implement consistent sorting and filtering logic across different social media applications. By using a common format, it becomes easier to integrate and extend sorting algorithms, providing a better user experience.

## Compatibility

This proposal is designed to be backward compatible with existing implementations by providing default values for new configuration fields. Platforms can gradually adopt the new configuration format without disrupting current functionality.

## Implementation

To implement this proposal, social media platforms should:

Parse the provided JSON configuration.
Apply sorting and filtering logic based on the specified parameters and metadata.
Ensure that user-specific settings are respected during the sorting and filtering process.

## Conclusion

This NIP provides a structured approach to sorting and filtering social media posts, enhancing user experience through customizable and consistent configurations. Adoption of this standard can lead to improved engagement and satisfaction on social media platforms. One that immediately stands out is encrption/decrpytion of this object at the client as a user's algorithm can be personally identifiable.

This draft can be further refined based on feedback and additional requirements. Let me know if there are specific sections you would like to expand or modify.