Commit graph

341 commits

Author SHA1 Message Date
Benjamin Neff
b274cc3dad
Fix some validators for nil values
Using the real entities for the tests also uncovered some bugs where for
example empty strings are converted to nil and the validation wasn't
invalid in this case, but should be.
2018-02-14 01:50:39 +01:00
Benjamin Neff
32a49cc549
Get optional props from validated object
This is much easier and safer than "guessing" the class name based on
the validator name. That can cause a problem when another class with the
same name is found. The "guessing" was only added because we used
OpenStruct in the tests, but we shouldn't change the code only to make
tests run. I changed the tests to use the real entities, with
auto-validation disabled in the constructor, so we can test the
validator manually.
2018-02-14 01:37:20 +01:00
Benjamin Neff
392f1f5a18
Fix relayable signatures for messages with invalid XML characters
Sometimes messages contain characters that are invalid for XML, but they
are filteres out before creating the XML, otherwise the property would
be empty in the XML.

But for relayables the value is also used for creating the signatures,
so we need to filter the invalid characters earlier, before calculating
the signature.
2018-01-25 01:52:34 +01:00
Benjamin Neff
0ff382248a
Fix warning about shared example group 'a signable' been defined twice 2018-01-22 04:13:45 +01:00
Benjamin Neff
5e81760f30
Remove participants limit for conversations
The limit was added in 2012 to prevent spam, but since the participants
need to be a mutual contact with the author nowadays, I don't think it's
a spam problem anymore.

I also added a validation for the minimum count of the participants,
because a conversion without participants doesn't make much sense.
2018-01-18 02:50:04 +01:00
cmrd Senya
03d779ef39
Merge pull request #90 from SuperTux88/fix-booleans-for-relayables
Fix when booleans in relayables are false
2018-01-10 16:31:31 +02:00
Benjamin Neff
45dc3d5dc3
Refactor AccountMigration::Signable spec without mocking 2017-12-27 20:03:59 +01:00
Benjamin Neff
d9a02119b8
Merge pull request #89 from cmrd-senya/account_migration_changes
Extract singning of AccountMigration to a different module and introduce alternative form for account migration message
2017-12-27 20:03:17 +01:00
cmrd Senya
7e2321d6c9 Introduce alternative form of the account migration message
In the alternative form author can be the new diaspora user
2017-12-27 18:37:49 +02:00
cmrd Senya
69e523abd0 Extract account migration sign feature to a module
This module can be used to compute account migration signature in other
objects besides Entities::AccountMigration. For instance this is to be
used in AccountMigration model of diaspora* web application.
2017-12-27 18:37:48 +02:00
Senya
c8568f7256
Merge pull request #80 from SuperTux88/blocking-flag
Add blocking flag to contact message
2017-12-23 17:08:48 +02:00
Benjamin Neff
7503e9a804
Fix when booleans in relayables are false
This was a problem with dislikes.

It's safe to use `to_s` here, because we have only strings, numbers and
booleans here anyway, because relayables don't support nested entities.
`to_s` is used to generate the `signature_data` string too.
2017-11-05 01:12:19 +01:00
Benjamin Neff
142950c99e
Merge pull request #84 from SuperTux88/reshare-remove-public-flag
Reshare remove public flag
2017-09-23 01:38:11 +02:00
Senya
181d11d2f5 Merge pull request #87 from SuperTux88/fetch-only-once
Don't fetch the same entity twice in the same thread
2017-09-23 02:25:53 +03:00
Benjamin Neff
8535cfc1df
Don't fetch the same entity twice in the same thread 2017-09-23 01:19:10 +02:00
Senya
0b358a6c44 Merge pull request #81 from SuperTux88/relay-likes-for-comments
Relay likes for comments
2017-09-23 00:33:11 +03:00
Benjamin Neff
61c00b3596
Use top parent when relaying relayables of relayables 2017-09-22 21:30:09 +02:00
Benjamin Neff
b25e21f980
Add method to get the top entity to RelatedEntity 2017-09-22 21:30:09 +02:00
Senya
cddb4610c0 Merge pull request #79 from SuperTux88/validate-public-flag-for-profiles
Allow to receive non-public profiles without private data
2017-09-22 14:11:58 +03:00
Benjamin Neff
5bf0087e0a
Bump rubocop
... and update the config and code for the new version.
2017-09-16 03:23:41 +02:00
Dennis Schubert
f9b24b15f8
Disallow diaspora* IDs longer than 255 characters 2017-09-13 12:35:08 +02:00
Dennis Schubert
4f87ab1582
Add tests for not validating uppercase characters 2017-09-13 11:51:34 +02:00
Benjamin Neff
b6ec405e55
Add author to the diaspora:// URL parser 2017-09-12 23:46:42 +02:00
Benjamin Neff
e663a65c7e
Remove not_nil for diaspora IDs from validators
The diaspora ID validator now is not nil by default.

Also:
* mark root_author as optional for reshares.
* make author for profiles mandatory (I don't remember why this was
optional, we never generate a profile without author and we wouldn't
receive a profile without author anyway, because we validate that the
author is the sender).
* refactor validator specs for diaspora IDs
2017-09-12 23:11:05 +02:00
Benjamin Neff
5e3f510a88
Refactor diaspora ID regex to be used in diaspora:// URL regex 2017-09-12 23:11:05 +02:00
Benjamin Neff
35efeb8345
Move public flag from status_message to post
This represents the current state of the documentation.
2017-09-12 00:45:59 +02:00
Benjamin Neff
b1b511b6f7
Remove public and provider_display_name from reshare entity
Also don't extend from Post module anymore to represent the future state
of a reshare as it's own type only used to increase the reach of a post.

See #83
2017-09-12 00:13:21 +02:00
Benjamin Neff
834d358eca
Allow to receive non-public profiles without private data 2017-09-11 21:38:46 +02:00
cmrd Senya
0b07b36017
Merge pull request #74 from SuperTux88/parse-rfc-7033-webfinger
Parse RFC 7033 webfinger
2017-09-10 16:30:38 +03:00
Benjamin Neff
f24dd528ee
Add option for RFC 7033 WebFinger http fallback 2017-09-10 03:08:13 +02:00
Benjamin Neff
3e7e649025
Fetch RFC 7033 WebFinger with fallback to legacy WebFinger 2017-09-10 03:08:12 +02:00
Benjamin Neff
6852f9ca36
Add support to parse RFC 7033 WebFinger JSON
Also:
* Fix date format when generating JRD document
* Sort elements always with the same order
2017-09-05 22:56:22 +02:00
Benjamin Neff
db1034904d
Add blocking flag to contact message 2017-09-05 01:22:54 +02:00
Benjamin Neff
add5e16abf
Fetch linked entities from received entities with text 2017-09-04 23:48:31 +02:00
Benjamin Neff
0b927290e3
Add DiasporaUrlParser to extract diaspora:// URLs from texts 2017-09-04 23:48:31 +02:00
Benjamin Neff
faf48e1dd4
Extract allowed chars for GUIDs to constant
Also: disallow special chars at the end of a GUID
2017-09-04 23:48:29 +02:00
Benjamin Neff
b2eda1d812
Remove nilable parameter from guid rule and use OptionalAwareValidator 2017-09-03 20:10:25 +02:00
Benjamin Neff
860aec96b9
Make height and width optional for photos 2017-09-03 20:10:24 +02:00
Benjamin Neff
6f936caddf
Add abstract OptionalAwareValidator class
This improves validation of optional fields and respects the `optional`
option of properties
2017-09-03 20:10:24 +02:00
Benjamin Neff
458d0f2215
Always raise a DiscoveryError when something with the discovery fails 2017-09-01 01:51:36 +02:00
cmrd Senya
69996319e1
Minor change PhotoValidator#status_message_guid spec
Use new "a nilable guid validator" shared behavior
2017-08-25 10:41:22 +03:00
cmrd Senya
5b12afebed
Allow reshares with no root 2017-08-25 10:33:16 +03:00
Benjamin Neff
8efb368a96
Merge pull request #71 from SuperTux88/optional-properties
Don't add optional properties to generated XML and JSON when nil
2017-08-07 23:18:56 +02:00
Benjamin Neff
93e18e1a79
Add DiasporaFederation::Schemas to access JSON schema 2017-08-01 20:17:55 +02:00
Benjamin Neff
bb40d6190d
Only add optional nil values to relayable XML when needed for signature order 2017-07-30 00:32:54 +02:00
Benjamin Neff
f5ff4a71e6
Only add optional properties to generated XML and JSON when not nil 2017-07-30 00:32:54 +02:00
Benjamin Neff
af7b6485ac
Mark properties as optional 2017-07-30 00:32:54 +02:00
Benjamin Neff
e26a86c173
Switch PercentLiteralDelimiters to new default
Let's change that to the new rubocop default, which is also the
suggestion in the ruby style guide.

See https://github.com/bbatsov/ruby-style-guide#percent-literal-braces

This was changed in diaspora too, see diaspora/diaspora#7466

It also includes the changes in the code. This was done with
`rubocop --auto-correct` and no we have zero offenses again.
2017-06-30 02:23:44 +02:00
cmrd Senya
5730b88296 Merge pull request #67 from SuperTux88/comments-created_at
Add created_at to comment
2017-06-20 15:59:35 +03:00
Benjamin Neff
c0ea38d258
Improve logging when validation fails
Add guid and author to error messages if available.
2017-06-11 16:01:04 +02:00