Commit Graph

891 Commits

Author SHA1 Message Date
marcin mikołajczak b7c625db0f Merge remote-tracking branch 'origin/develop' into link-verification 2024-03-07 13:13:49 +01:00
tusooa 47ce33a90d Apply tusooa's suggestion 2024-03-07 11:55:31 +00:00
Mark Felder a266492776 Pleroma.User: dialyzer errors
lib/pleroma/user.ex:757:no_return
Function register_changeset/1 has no local return.
________________________________________________________________________________
lib/pleroma/user.ex:757:no_return
Function register_changeset/2 has no local return.
________________________________________________________________________________
lib/pleroma/user.ex:757:no_return
Function register_changeset/3 has no local return.
________________________________________________________________________________
lib/pleroma/user.ex:778:call
The function call will not succeed.

Pleroma.User.approval_changeset(
  %Ecto.Changeset{
    :action => atom(),
    :changes => %{atom() => _},
    :constraints => [
      %{
        :constraint =>
          binary()
          | %Regex{
              :opts => binary() | [any()],
              :re_pattern => _,
              :re_version => _,
              :source => binary()
            },
        :error_message => binary(),
        :error_type => atom(),
        :field => atom(),
        :match => :exact | :prefix | :suffix,
        :type => :check | :exclusion | :foreign_key | :unique
      }
    ],
    :data => nil | map(),
    :empty_values => _,
    :errors => Keyword.t({binary(), Keyword.t()}),
    :filters => %{atom() => _},
    :params => nil | %{binary() => _},
    :prepare => [(_ -> any())],
    :repo => atom(),
    :repo_opts => Keyword.t(),
    :required => [atom()],
    :types =>
      nil
      | %{
          atom() =>
            atom()
            | {:array | :assoc | :embed | :in | :map | :maybe | :param, _}
            | {:parameterized, atom(), _}
        },
    :valid? => boolean(),
    :validations => Keyword.t()
  },
  [{:set_approval, _}, ...]
)

breaks the contract
(t(), :elixir.keyword()) :: Ecto.Changeset.t()

________________________________________________________________________________
lib/pleroma/user.ex:854:unused_fun
Function maybe_validate_required_birthday/1 will never be called.
2024-01-29 17:37:52 -05:00
Haelwenn 251c455b91 Merge branch 'deps-bump' into 'develop'
Bump dependencies

See merge request pleroma/pleroma!4044
2024-01-29 17:43:00 +00:00
Mark Felder 082d665160 Pleroma.Web.AdminAPI.UserController: dialyzer errors
lib/pleroma/web/admin_api/controllers/user_controller.ex:205:no_return
Function activate/2 has no local return.
________________________________________________________________________________
lib/pleroma/web/admin_api/controllers/user_controller.ex:215:call
The function call will not succeed.

Keyword.values(
  _updated_users :: %Pleroma.User{
    :__meta__ => _,
    :accepts_chat_messages => _,
    :actor_type => _,
    :allow_following_move => _,
    :also_known_as => _,
    :ap_id => _,
    :avatar => _,
    :background => _,
    :banner => _,
    :bio => _,
    :birthday => _,
    :blocked_users => _,
    :blockee_blocks => _,
    :blocker_blocks => _,
    :blocker_users => _,
    :blocks => _,
    :confirmation_token => _,
    :default_scope => _,
    :deliveries => _,
    :disclose_client => _,
    :domain_blocks => _,
    :email => _,
    :email_notifications => _,
    :emoji => _,
    :endorsed_users => _,
    :endorsee_endorsements => _,
    :endorser_endorsements => _,
    :endorser_users => _,
    :featured_address => _,
    :fields => _,
    :follower_address => _,
    :follower_count => _,
    :following_address => _,
    :following_count => _,
    :hide_favorites => _,
    :hide_followers => _,
    :hide_followers_count => _,
    :hide_follows => _,
    :hide_follows_count => _,
    :id => _,
    :inbox => _,
    :incoming_relationships => _,
    :inserted_at => _,
    :invisible => _,
    :is_active => _,
    :is_admin => _,
    :is_approved => _,
    :is_confirmed => _,
    :is_discoverable => _,
    :is_locked => _,
    :is_moderator => _,
    :is_suggested => _,
    :keys => _,
    :language => _,
    :last_active_at => _,
    :last_digest_emailed_at => _,
    :last_refreshed_at => _,
    :last_status_at => _,
    :local => _,
    :mascot => _,
    :multi_factor_authentication_settings => _,
    :muted_notifications => _,
    :muted_reblogs => _,
    :muted_users => _,
    :mutee_mutes => _,
    :muter_mutes => _,
    :muter_users => _,
    :mutes => _,
    :name => _,
    :nickname => _,
    :no_rich_text => _,
    :note_count => _,
    :notification_muted_users => _,
    :notification_mutee_mutes => _,
    :notification_muter_mutes => _,
    :notification_muter_users => _,
    :notification_settings => _,
    :notifications => _,
    :outgoing_relationships => _,
    :password => _,
    :password_confirmation => _,
    :password_hash => _,
    :password_reset_pending => _,
    :pinned_objects => _,
    :pleroma_settings_store => _,
    :public_key => _,
    :raw_bio => _,
    :raw_fields => _,
    :reblog_muted_users => _,
    :reblog_mutee_mutes => _,
    :reblog_muter_mutes => _,
    :reblog_muter_users => _,
    :registration_reason => _,
    :registrations => _,
    :search_rank => _,
    :search_type => _,
    :shared_inbox => _,
    :show_birthday => _,
    :show_role => _,
    :skip_thread_containment => _,
    :subscribee_subscriptions => _,
    :subscribee_users => _,
    :subscriber_subscriptions => _,
    :subscriber_users => _,
    :subscribers => _,
    :tags => _,
    :updated_at => _,
    :uri => _
  }
)

will never return since the success typing is:
([any()]) :: [any()]

and the contract is
(t()) :: [value()]

________________________________________________________________________________
lib/pleroma/web/admin_api/controllers/user_controller.ex:218:no_return
Function deactivate/2 has no local return.
________________________________________________________________________________
lib/pleroma/web/admin_api/controllers/user_controller.ex:228:call
The function call will not succeed.

Keyword.values(
  _updated_users :: %Pleroma.User{
    :__meta__ => _,
    :accepts_chat_messages => _,
    :actor_type => _,
    :allow_following_move => _,
    :also_known_as => _,
    :ap_id => _,
    :avatar => _,
    :background => _,
    :banner => _,
    :bio => _,
    :birthday => _,
    :blocked_users => _,
    :blockee_blocks => _,
    :blocker_blocks => _,
    :blocker_users => _,
    :blocks => _,
    :confirmation_token => _,
    :default_scope => _,
    :deliveries => _,
    :disclose_client => _,
    :domain_blocks => _,
    :email => _,
    :email_notifications => _,
    :emoji => _,
    :endorsed_users => _,
    :endorsee_endorsements => _,
    :endorser_endorsements => _,
    :endorser_users => _,
    :featured_address => _,
    :fields => _,
    :follower_address => _,
    :follower_count => _,
    :following_address => _,
    :following_count => _,
    :hide_favorites => _,
    :hide_followers => _,
    :hide_followers_count => _,
    :hide_follows => _,
    :hide_follows_count => _,
    :id => _,
    :inbox => _,
    :incoming_relationships => _,
    :inserted_at => _,
    :invisible => _,
    :is_active => _,
    :is_admin => _,
    :is_approved => _,
    :is_confirmed => _,
    :is_discoverable => _,
    :is_locked => _,
    :is_moderator => _,
    :is_suggested => _,
    :keys => _,
    :language => _,
    :last_active_at => _,
    :last_digest_emailed_at => _,
    :last_refreshed_at => _,
    :last_status_at => _,
    :local => _,
    :mascot => _,
    :multi_factor_authentication_settings => _,
    :muted_notifications => _,
    :muted_reblogs => _,
    :muted_users => _,
    :mutee_mutes => _,
    :muter_mutes => _,
    :muter_users => _,
    :mutes => _,
    :name => _,
    :nickname => _,
    :no_rich_text => _,
    :note_count => _,
    :notification_muted_users => _,
    :notification_mutee_mutes => _,
    :notification_muter_mutes => _,
    :notification_muter_users => _,
    :notification_settings => _,
    :notifications => _,
    :outgoing_relationships => _,
    :password => _,
    :password_confirmation => _,
    :password_hash => _,
    :password_reset_pending => _,
    :pinned_objects => _,
    :pleroma_settings_store => _,
    :public_key => _,
    :raw_bio => _,
    :raw_fields => _,
    :reblog_muted_users => _,
    :reblog_mutee_mutes => _,
    :reblog_muter_mutes => _,
    :reblog_muter_users => _,
    :registration_reason => _,
    :registrations => _,
    :search_rank => _,
    :search_type => _,
    :shared_inbox => _,
    :show_birthday => _,
    :show_role => _,
    :skip_thread_containment => _,
    :subscribee_subscriptions => _,
    :subscribee_users => _,
    :subscriber_subscriptions => _,
    :subscriber_users => _,
    :subscribers => _,
    :tags => _,
    :updated_at => _,
    :uri => _
  }
)

will never return since the success typing is:
([any()]) :: [any()]

and the contract is
(t()) :: [value()]
2024-01-28 17:14:37 -05:00
Mark Felder 5b95abaeea Credo.Check.Readability.PredicateFunctionNames
This check was recently improved in Credo and it does make sense for readability.

The offending functions in Pleroma have been renamed and a couple missing the ? suffix have been fixed as well.
2024-01-26 16:59:58 -05:00
Mark Felder c7eda0b24a Use config to control loading of custom modules 2024-01-20 18:43:53 -05:00
Mark Felder 2fbb67add7 Fix typo in typespec 2024-01-20 17:48:12 -05:00
Mark Felder ea26add540 Fix incorrect type definition for maybe_direct_follow/2 2024-01-20 17:43:34 -05:00
Mark Felder 0b7d214211 Fix invalid typespec references to Ecto.Changeset.t() 2024-01-20 16:47:50 -05:00
tusooa 7a58ddfa48
Allow local user to have group actor type
https://git.pleroma.social/pleroma/pleroma/-/issues/3205
2023-12-27 12:27:37 -05:00
marcin mikołajczak 28e5e65676 Merge remote-tracking branch 'origin/develop' into webfinger-fix
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2023-12-22 13:29:56 +01:00
marcin mikołajczak 39d3df86c8 Use consistent terminology
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2023-12-21 00:10:30 +01:00
Mark Felder 9896b64f54 Elixir 1.15: Chase the Logger.warn deprecation 2023-12-20 20:16:26 +00:00
Lain Soykaf c212fc1dcf User: Ignore non-local users when setting 'last active at' 2023-12-16 20:32:13 +04:00
Mark Felder c0a50b7c3e User.get_or_fetch_public_key_for_ap_id/1 is no longer required. 2023-12-10 13:24:25 -05:00
Mark Felder 94daa3e8c1 Revert "Remove unnecessary forced refresh of user"
This reverts commit 97cf78f63d.
2023-12-09 18:21:00 -05:00
Mark Felder 97cf78f63d Remove unnecessary forced refresh of user 2023-12-08 18:24:30 -05:00
Mark Felder ce5acd4158 get_cached_by_ap_id/1 returns a single result, not a tuple 2023-12-08 18:10:22 -05:00
Mark Felder 074b31d9ab Optimistic Inbox
Rework inbound federation to accept requests optimistically. The HTTP Signatures Plug will not attempt to fetch the actor or key and will fail early.

If the signature cannot be validated we pass the required data into the Oban job with a reduced priority and increase the timeout to 20 seconds. The Oban job will handle the actor and key fetching before attempting to validate the activity again. This job will be retried 5 times by default.

Another welcome side effect is that actors who change their keys can federate to Pleroma instances immediately instead of needing to wait the default value of 86400s / 24 hours before the key will be fetched again.
2023-12-08 17:45:20 -05:00
marcin mikołajczak 50e7706b26 Verify link ownership with rel="me"
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2023-11-02 13:30:46 +01:00
marcin mikołajczak 5ff3783d01 Use correct domain for fqn and InstanceView
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2023-10-25 00:38:10 +02:00
Haelwenn (lanodan) Monnier fcd49e3985 User: Remove ap_enabled field 2023-05-05 11:11:26 +02:00
Haelwenn (lanodan) Monnier 238edc30de User: Remove ap_enabled?/1 2023-05-05 11:11:26 +02:00
Haelwenn (lanodan) Monnier 0903c41645 User: Stop relying on ap_enabled 2023-05-05 11:11:26 +02:00
lain e853cfe7c3 Revert "Merge branch 'copyright-bump' into 'develop'"
This reverts merge request !3825
2023-01-02 20:38:50 +00:00
marcin mikołajczak 10886eeaa2 Bump copyright year
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2023-01-01 12:13:06 +01:00
Sean King 60df2d8a97
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into fine_grained_moderation_privileges 2022-12-18 22:03:48 -07:00
tusooa a3985aac91 Merge branch 'fix-2856' into 'develop'
Uploading an avatar media exceeding max size returns a 413

Closes #2856

See merge request pleroma/pleroma!3804
2022-12-16 16:15:36 +00:00
tusooa 62c27e0164
Fix failure when registering a user with no email when approval required 2022-12-14 01:04:42 -05:00
duponin 452595baed Uploading an avatar media exceeding max size returns a 413
Until now it was returning a 500 because the upload plug were going
through the changeset and ending in the JSON encoder, which raised
because struct has to @derive the encoder.
2022-12-11 22:54:47 +01:00
Tusooa Zhu 50923f5438
Fix User.get_or_fetch/1 with usernames starting with http 2022-09-08 11:58:17 -04:00
Hélène cd237d22f1
User: generate private keys on user creation
This fixes a race condition bug where keys could be regenerated
post-federation, causing activities and HTTP signatures from an user to
be dropped due to key differences.
2022-09-05 03:51:17 +02:00
floatingghost f2a9285ff0
bugfix/follow-state (#104)
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/104
2022-08-03 01:07:53 -04:00
tusooa c80096522c Merge branch 'develop' into 'from/develop/tusooa/emit-move'
# Conflicts:
#   CHANGELOG.md
#   test/pleroma/user_test.exs
2022-07-31 21:32:49 +00:00
marcin mikołajczak 5d3d6a58f7 Use `duration` param for mute expiration duration
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-07-31 17:22:34 +02:00
tusooa 301ce5bc62 Merge branch 'mute-expiration' into 'develop'
MastoAPI: Show mutes expiration date

See merge request pleroma/pleroma!3682
2022-07-23 00:34:15 +00:00
marcin mikołajczak 597f56b4c4 Use :utc_datetime
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-07-16 16:28:22 +02:00
Ilja 44d14e8a9c Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into fine_grained_moderation_privileges 2022-07-14 07:07:19 +02:00
Tusooa Zhu 8bb2e52d2e
Make lint happy 2022-07-10 23:43:49 -04:00
Sean King 6e7b919637
Make validation functions for restricted nicknames and blacklisted domains; do restricted nickname validation in LDAP account registration 2022-07-06 20:15:49 -06:00
Sean King 0d4aceb9b0
Make checking blacklisted domains and restricted nicknames case-insenstive 2022-07-05 20:36:47 -06:00
Ilja 37fdf148b0 Rename privilege tags
I first focussed on getting things working
Now that they do and we know what tags there are, I put some thought in providing better names

I use the form <what_it_controls>_<what_it_allows_you_to_do>

:statuses_read    => :messages_read
:status_delete    => :messages_delete

:user_read        => :users_read
:user_deletion    => :users_delete
:user_activation  => :users_manage_activation_state
:user_invite      => :users_manage_invites
:user_tag         => :users_manage_tags
:user_credentials => :users_manage_credentials

:report_handle    => :reports_manage_reports

:emoji_management => :emoji_manage_emoji
2022-07-01 10:28:09 +02:00
Ilja 211e561e2a Show privileges to FE
I added an extra key
We already had is_admin and is_moderator, now we have an extra privileges key
2022-06-21 12:10:27 +02:00
Ilja 34adea8d28 Add Pleroma.User.all_users_with_privilege/1
This should eventually replace the Pleroma.User.all_superusers/0 function

* I added a new param `is_privileged` in User.query
* Now we can fetch all users with a specified privilege
2022-06-21 12:10:27 +02:00
Ilja a1c8aa4721 Remove function superuser?
Everything now happens with privileged?/2
2022-06-21 12:10:27 +02:00
Ilja e45faddb38 Revert "Delete report notifs when demoting from superuser"
This reverts commit 89667189b8 and cdc5bbe836.

This is a side effect when changing user role.
The goal was to not have report notifications when someone isn't admin or moderator any more.
But this won't be triggered when we change the privilege tags for a role, so we can't use this sollution any more.
There was another solution to filter out report notifications during fetch.
It wasn't merged because this seemed 'cleaner' at the time, but now it seems the better sollution.
I'll add it in the next commit.
2022-06-21 12:10:27 +02:00
Ilja edf0013ff3 User.visible_for/2
According to the tests, this was only used for unconfirmed accounts.
So this just needed to be restricted to users with privilege :user_activation
2022-06-21 12:10:27 +02:00
Ilja 7adfc2e0f4 Add Pleroma.User.privileged?/2
This should eventually replace Pleroma.User.superuser?/1
2022-06-21 12:10:27 +02:00
marcin mikołajczak b0f83aea29 Store mutes expiration date
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-06-16 20:38:37 +02:00