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

feat: Add support for events #10628

Open
wants to merge 62 commits into
base: develop
Choose a base branch
from

Conversation

ssmucny
Copy link
Contributor

@ssmucny ssmucny commented Apr 14, 2023

What

Adding support for events in Misskey. See #3217

New Event type

Implemented like Polls (a Note can have a child event in the database). The event data will show above the normal content of displayed notes if present.

The required values in a child event are start and title. The end and metadata are optional. The metadata is an Schema.org JSON object of type Event. The event editor provides the ability for users to specify elements in the metadata, but the API endpoint can support more properties than the UI.

New API for searching Events

New endpoint created at /notes/events/search that queries events. Similar parameters to other searches with changes for Event specific values. The major addition are new filter options. These are objects that filter events based on metadata. Each object is treated as a separate AND condition. Each object contains a key array that selects the metadata property to filter on (ex: ["location", "postalCode"] selects location.postalCode in the Event metadata. Each object also has an array of string values that are considered as OR conditions for their respective metadata property. So if the prior location.postaCode selection wanted to select all events that had postal code 44113 and 44114 then they would use ["44113","44114"]. A value of null indicates that a missing value in the event is matched.

The individual values are interpreted as case insensitive regex values, so the user could run more complicated matches themselves; however, because regex is accepted, there is a timeout placed on the query (250 ms) to prevent long running queries from hurting performance (advice from Postgres docs). There can be multiple filters using the same metadata key, and these will have the effect of an AND condition on the same metadata value with two different match clauses.

The original issue has a proposal for an alternative API using a query string parameters in the URL. This PR does not implement this, but it could be implemented in a separate PR.

Event display component

A new Vue component to display events in notes was created. It formats the note information at the top of the note. Other note stuff is still accessible.
image

User Events page

Added a tab in the user details page to show their events. The events can be displayed in reverse chronological order (normal display order) or with events shown in date order (starting with the events that are most imminent). If showing imminent events, then past events are not shown.
image

Search Events page

Added a tab in the search page to search events. There is a custom form with parameters relevant to searching events. This includes a query string that searches the title and text of events, start/end date filters, and a option to change the sort order (like with the User Events page). Currently form elements to specify user filters and metadata filters are not included (using the API directly is the only way to filter with them). These should be added in a later PR.
image

Event editor

Added an option in the note creation dialogue to make a note an event. When selected, extra forms appear where the user can fill in details. The title and start date/time are required while the rest are optional. A toggle is present that hides most of the advanced options unless needed.
image

Why

Enable users to create events to share and track activities that occur at a particular time.

Additional info

Implementation progress:

  • new Event table that is One-to-One with Note
  • services/queries to manage events
  • update API endpoints to include events (notes/[create|delete|show])
  • Document new API changes
  • new API endpoints to search events (notes/events/search)
  • UI elements to display events
  • UI elements to create events
  • Event export (iCal) (maybe)
  • Event federation (Activity Pub Event)
  • RSVP (maybe)
  • Edit Note/Event (and federate) (Editing notes #8362) (maybe)

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Update CHANGELOG.md
  • (If possible) Add tests

@github-actions github-actions bot added the packages/backend Server side specific issue/PR label Apr 14, 2023
@ssmucny ssmucny mentioned this pull request Apr 14, 2023
@codecov
Copy link

codecov bot commented Apr 14, 2023

Codecov Report

Merging #10628 (8ec1182) into develop (39d9172) will increase coverage by 0.49%.
The diff coverage is 98.78%.

@@             Coverage Diff             @@
##           develop   #10628      +/-   ##
===========================================
+ Coverage    78.78%   79.27%   +0.49%     
===========================================
  Files          924      178     -746     
  Lines        97580    23325   -74255     
  Branches      7776      520    -7256     
===========================================
- Hits         76878    18491   -58387     
+ Misses       20702     4834   -15868     
Files Changed Coverage Δ
...es/frontend/src/components/MkDateSeparatedList.vue 57.93% <50.00%> (+0.38%) ⬆️
packages/frontend/src/components/MkEvent.vue 100.00% <100.00%> (ø)
packages/frontend/src/components/MkEventEditor.vue 100.00% <100.00%> (ø)
packages/frontend/src/components/MkNote.vue 100.00% <100.00%> (ø)
packages/frontend/src/components/MkNotes.vue 100.00% <100.00%> (ø)
packages/frontend/src/components/MkPostForm.vue 100.00% <100.00%> (ø)

... and 750 files with indirect coverage changes

name = 'Event1681429921400'

async up(queryRunner) {
await queryRunner.query(`DROP INDEX "public"."IDX_2cd3b2a6b4cf0b910b260afe08"`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The migration generated appears to have a bunch of extraneous modifications. Should these be removed so that only the new Event related modifications are included?

@misskey-dev misskey-dev deleted a comment from remador Apr 14, 2023
@misskey-dev misskey-dev deleted a comment from remador Apr 14, 2023
@misskey-dev misskey-dev deleted a comment from remador Apr 14, 2023
@github-actions github-actions bot added the packages/frontend Client side specific issue/PR label Apr 18, 2023
@tamaina
Copy link
Contributor

tamaina commented Jul 10, 2023

I honestly can't think of a situation where I would use it, but if there was a webcal (iCal) link, I might want to use it.

@ThatOneCalculator
Copy link
Contributor

I'm currently adapting this PR, and using ics for iCal generation

@tamaina
Copy link
Contributor

tamaina commented Jul 10, 2023

Need to get @syuilo to review the design of the content in the note.

@syuilo
Copy link
Member

syuilo commented Jul 10, 2023

見る

@syuilo
Copy link
Member

syuilo commented Jul 28, 2023

見てる

@syuilo
Copy link
Member

syuilo commented Jul 28, 2023

半分くらい見た
これってMastodonとか他のソフトウェアは対応してるのかな

@acid-chicken
Copy link
Member

Event 実装といえば Friendica が挙がりそうだけど連合できるかしら

@ssmucny
Copy link
Contributor Author

ssmucny commented Jul 31, 2023

Friendica and Mobilizon both have ActivityPub Events. They have some extensions to the base object.

Friendica: https://activitystrea.ms/head/activity-schema.html#event, https://github.com/friendica/friendica/wiki/ActivityStreams#activity_obj_event
Mobilizon: https://docs.joinmobilizon.org/contribute/activity_pub/#event_1
ActivityPub: https://www.w3.org/TR/activitystreams-vocabulary/#dfn-event

Mastodon does not have Events

@syuilo
Copy link
Member

syuilo commented Aug 2, 2023

概ね良さそう
ただEventという名前がプログラミングにおいては一般的すぎるから変えた方が良いかもと思った

@syuilo
Copy link
Member

syuilo commented Aug 2, 2023

例えばEventが必ずNoteと紐づけられるのであればNoteEventとか?

@syuilo
Copy link
Member

syuilo commented Aug 2, 2023

あとはEventAnnoucementとか思いついた

@tamaina
Copy link
Contributor

tamaina commented Aug 2, 2023

Eventから離れたほうが良いと思う

Scheduleとか…Programとか…あれ、両方コンピュータで使われがちだ…

@tamaina
Copy link
Contributor

tamaina commented Aug 2, 2023

Sessionもまずい

@syuilo
Copy link
Member

syuilo commented Aug 2, 2023

Off topic:
突き詰めて考えると全てのドメイン固有概念にはVueコンポーネントでやってるみたいにMkを接頭辞として付けるみたいなの思いついた

@ssmucny
Copy link
Contributor Author

ssmucny commented Aug 6, 2023

例えばEventが必ずNoteと紐づけられるのであればNoteEventとか?

I like this idea. 'Event' is already used in the repository to refer to other objects, so changing the name to 'NoteEvent' internally would help to disambiguate.

@syuilo
Copy link
Member

syuilo commented Aug 9, 2023

Off topic: 突き詰めて考えると全てのドメイン固有概念にはVueコンポーネントでやってるみたいにMkを接頭辞として付けるみたいなの思いついた

#11496

Comment on lines +37 to +44
@Column('jsonb', {
default: {
'@context': 'https://schema.org/',
'@type': 'Event',
},
comment: 'metadata object describing the event. Follows https://schema.org/Event',
})
public metadata: EventSchema;
Copy link
Member

Choose a reason for hiding this comment

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

スキーマが予め決まっているデータだからJSONBでまとめて持つ必要はなさそう

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Schema.org has a defined schema, but not all platforms implement the same properties from it. Keeping it in JSONB ensures compatibility with other sources and flexibility if we want to support other properties later. Some common/required properties like 'start time' and 'end time' that will be queried/ordered often are included as their own SQL fields with indexes even if that adds some redundancy with the JSONB object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages/backend Server side specific issue/PR packages/frontend Client side specific issue/PR packages/misskey-js
Projects
Development

Successfully merging this pull request may close these issues.

5 participants