misskey icon indicating copy to clipboard operation
misskey copied to clipboard

feat: Add support for events

Open ssmucny opened this issue 1 year ago • 18 comments

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:

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

Checklist

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

ssmucny avatar Apr 14 '23 00:04 ssmucny

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%) :arrow_up:
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

codecov[bot] avatar Apr 14 '23 00:04 codecov[bot]

This PR has all the major features added and is ready for reviews.

ssmucny avatar Jun 22 '23 00:06 ssmucny

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.

tamaina avatar Jul 10 '23 04:07 tamaina

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

ThatOneCalculator avatar Jul 10 '23 04:07 ThatOneCalculator

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

tamaina avatar Jul 10 '23 04:07 tamaina

見る

syuilo avatar Jul 10 '23 05:07 syuilo

見てる

syuilo avatar Jul 28 '23 03:07 syuilo

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

syuilo avatar Jul 28 '23 08:07 syuilo

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

acid-chicken avatar Jul 28 '23 11:07 acid-chicken

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

ssmucny avatar Jul 31 '23 02:07 ssmucny

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

syuilo avatar Aug 02 '23 11:08 syuilo

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

syuilo avatar Aug 02 '23 11:08 syuilo

あとはEventAnnoucementとか思いついた

syuilo avatar Aug 02 '23 11:08 syuilo

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

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

tamaina avatar Aug 02 '23 11:08 tamaina

Sessionもまずい

tamaina avatar Aug 02 '23 11:08 tamaina

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

syuilo avatar Aug 02 '23 11:08 syuilo

例えば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.

ssmucny avatar Aug 06 '23 22:08 ssmucny

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

https://github.com/misskey-dev/misskey/issues/11496

syuilo avatar Aug 09 '23 05:08 syuilo