Commit Graph

32 Commits

Author SHA1 Message Date
Eugen Rochko ddd30f331c
Improve support for aspects/circles ()
* Add silent column to mentions

* Save silent mentions in ActivityPub Create handler and optimize it

Move networking calls out of the database transaction

* Add "limited" visibility level masked as "private" in the API

Unlike DMs, limited statuses are pushed into home feeds. The access
control rules between direct and limited statuses is almost the same,
except for counter and conversation logic

* Ensure silent column is non-null, add spec

* Ensure filters don't check silent mentions for blocks/mutes

As those are "this person is also allowed to see" rather than "this
person is involved", therefore does not warrant filtering

* Clean up code

* Use Status#active_mentions to limit returned mentions

* Fix code style issues

* Use Status#active_mentions in Notification

And remove stream_entry eager-loading from Notification
2018-10-17 17:13:04 +02:00
Eugen Rochko 802cf6a4c5
Improve federated ID validation ()
* Fix URI not being sufficiently validated with prefetched JSON

* Add additional id validation to OStatus documents, when possible
2018-08-22 20:55:14 +02:00
ThibG c52bcc0331 Serialize text-less statuses as '.' over OStatus (fixes ) () 2018-08-05 12:22:23 +02:00
abcang 90908fc24b Fix N+1 on AtomSerializer () 2018-05-29 13:34:02 +02:00
Akihiko Odaki 55fd55714a Raise Mastodon::RaceConditionError if Redis lock failed ()
An explicit error allows user agents to know the error and Sidekiq to
retry.
2018-05-16 12:29:45 +02:00
Eugen Rochko 6208ea5a53
If an OStatus message contains nsfw hashtag, mark it as sensitive ()
* If an OStatus message contains nsfw hashtag, mark it as sensitive

Undo parts of 

* Put nsfw hashtag on OStatus messages if they have any media

* Fix code style issues
2018-05-07 14:49:13 +02:00
ThibG a24605961a Fixes/do not override timestamps ()
* Revert "Fixes/do not override timestamps ()"

This reverts commit 581a5c9d29.

* Document Snowflake ID corner-case a bit more

Snowflake IDs are used for two purposes: making object identifiers harder to
guess and ensuring they are in chronological order. For this reason, they
are based on the `created_at` attribute of the object.

Unfortunately, inserting items with older snowflakes IDs will break the
assumption of consumers of the paging APIs that new items will always have
a greater identifier than the last seen one.

* Add `override_timestamps` virtual attribute to not correlate snowflake ID with created_at
2018-05-03 23:02:46 +02:00
ThibG 581a5c9d29 Fixes/do not override timestamps ()
* Do not override timestamps for incoming toots

* Remove every reference to override_timestamps

Statuses are now created with the announced publishing date
and are only pushed to timelines if that date is at most
6 hours earlier than the time at which it is processed.
2018-05-03 13:33:08 +02:00
Eugen Rochko 75c4ab9d12
Remove "nsfw" category for sensitive statuses in OStatus serializer ()
Fix 
2018-04-22 22:09:03 +02:00
David Underwood 123a343d11 [WIP] Enable custom emoji on account pages and in the sidebar ()
Federate custom emojis with accounts
2018-04-01 23:55:42 +02:00
ThibG ff6b8a6443 Serialize mentions in the order they are added ()
Up until now, the order seemed to be in the *opposite* order,
which caused the WebUI to populate mentions in reversed order
when replying to toots local to one's instance.
2018-03-19 20:19:35 +01:00
Eugen Rochko f02411da40
Ignore media validation when attaching to status during processing ()
Fix 
2018-03-19 01:51:19 +01:00
MitarashiDango 6dcf96271e fix validation error (media only status) ()
* fix validation error (media only status)

* Incorporating review suggestions

* Reflect similar fix to OStatus side

* Fix not to include media in transaction

* Restore the limit of the number of media

* Fix not to return nil
2018-03-08 01:22:47 +01:00
Eugen Rochko a71af98401
Push discovered status through streaming API within a time window ()
Time window of 6 hours
2018-02-17 14:28:48 +01:00
Eugen Rochko 35b84985a8
Skip ActivityPub Announces of non-public objects ()
* Skip ActivityPub Announces of non-public objects

* Skip OStatus reblogs of non-public statuses
2018-01-09 19:35:10 +01:00
abcang 3caec1ecc2 Save media outside transaction () 2017-12-10 16:33:52 +01:00
Yamagishi Kazutoshi b21db9bbde Using double splat operator () 2017-12-06 11:41:57 +01:00
Eugen Rochko 484208ce12 When status is fetched instead of delivered, do not stream it () 2017-10-17 20:05:21 +02:00
Eugen Rochko df7dbc41ae Fix NameError: uninitialized constant OStatus::AtomSerializer::TagManager ()
This error occurred at least in development environment
2017-10-13 16:44:43 +02:00
Eugen Rochko 0717d9b3e6 Set snowflake IDs for backdated statuses ()
- Rename Mastodon::TimestampIds into Mastodon::Snowflake for clarity
- Skip for statuses coming from inbox, aka delivered in real-time
- Skip for statuses that claim to be from the future
2017-10-08 17:34:34 +02:00
Akihiko Odaki 63f0979799 Validate id of ActivityPub representations ()
Additionally, ActivityPub::FetchRemoteStatusService no longer parses
activities.
OStatus::Activity::Creation no longer delegates to ActivityPub because
the provided ActivityPub representations are not signed while OStatus
representations are.
2017-10-04 01:13:48 +02:00
ThibG 34fa305a00 Fix race condition when processing incoming OStatus messages ()
* Avoid races in incoming OStatus toots processing

* oops

* oops again
2017-09-19 21:44:18 +02:00
Akihiko Odaki bb4d005a83 Introduce OStatus::TagManager () 2017-09-19 18:08:08 +02:00
Eugen Rochko 81cec35dbf Custom emoji ()
* Custom emoji

- In OStatus: `<link rel="emoji" name="coolcat" href="http://..." />`
- In ActivityPub: `{ type: "Emoji", name: ":coolcat:", href: "http://..." }`
- In REST API: Status object includes `emojis` array (`shortcode`, `url`)
- Domain blocks with reject media stop emojis
- Emoji file up to 50KB
- Web UI handles custom emojis
- Static pages render custom emojis as `<img />` tags

Side effects:

- Undo  optimization, as I needed to modify it to restore
  shortcode handling in emojify()
- Formatter#plaintext should now make sure stripped out line-breaks
  and paragraphs are replaced with newlines

* Fix emoji at the start not being converted
2017-09-19 02:42:40 +02:00
Eugen Rochko e7adbf572a Switch to static URIs, new URI format in both protocols for new statuses ()
* Decouple Status#local? from uri being nil

* Replace on-the-fly URI generation with stored URIs

- Generate URI in after_save hook for local statuses
- Use static value in TagManager when available, fallback to tag format
- Make TagManager use ActivityPub::TagManager to understand new format
- Adjust tests

* Use other heuristic for locality of old statuses, do not perform long query

* Exclude tombstone stream entries from Atom feed

* Prevent nil statuses from landing in Pubsubhubbub::DistributionWorker

* Fix URI not being saved ()

* Add more specs for Status

* Save generated uri immediately

and also fix method order to minimize diff.

* Fix alternate HTML URL in Atom

* Fix tests

* Remove not-null constraint from statuses migration to speed it up
2017-09-06 19:01:28 +02:00
unarist 504737e860 Convert OStatus tag to ActivityPub id on in_reply_to resolution () 2017-09-01 13:34:04 +02:00
unarist af2d22f88c Fallback from perform_via_activitypub on private posts ()
Currently, private / direct posts via OStatus from AP compatible instance will be dropped due to failing to fetch AP version.

So this fallbacks to OStatus handling:

* when failed to fetch ActivityPub version
* when status is neither :public nor :unlisted
2017-09-01 12:33:02 +02:00
Eugen Rochko 4c76402ba1 Serialize ActivityPub alternate link into OStatus deletes, handle it ()
Requires moving Atom rendering from DistributionWorker (where
`stream_entry.status` is already nil) to inline (where
`stream_entry.status.destroyed?` is true) and distributing that.

Unfortunately, such XML renderings can no longer be easily chained
together into one payload of n items.
2017-08-29 16:11:05 +02:00
Eugen Rochko 40c45f5dd9 Put ActivityPub alternate link into Atom, prefer it when processing Atom () 2017-08-18 01:03:18 +02:00
Eugen Rochko 4fcbb1f838 Re-add missing transaction around status-from-OStatus creation () 2017-08-14 21:37:21 +02:00
Eugen Rochko a5a07da892 Correct OStatus inflection (Ostatus -> OStatus) () 2017-07-19 01:37:26 +02:00
Akihiko Odaki 89b988cab5 Introduce Ostatus name space ()
* Wrap methods of ProcessFeedService::ProcessEntry in classes

This is a change same with 425acecfdb, except
that it has the following changes:

* Revert irrelevant change in find_or_create_conversation
* Fix error handling for RemoteActivity

* Introduce Ostatus name space
2017-07-18 16:39:47 +02:00