Commit Graph

65 Commits

Author SHA1 Message Date
Matt Baer 7f96e8c384 Rename UserSuspended to UserSilenced
Some of the work needed to have the backend match user-facing wording.

Ref T661
2019-11-12 00:41:25 +09:00
Matt Baer f7550a0da8 Change more suspension check logic
From u.Status == UserSuspended to u.IsSuspended()

Ref T661
2019-11-12 00:04:36 +09:00
Rob Loranger f85f0751a3
address PR comments
- update error messages to be correct
- move suspended message into template and include for other pages
- check suspended status on all relevant pages and show message if
logged in user is suspended.
- fix possible nil pointer error
- remove changes to db schema files
- add version comment to migration
- add UserStatus type with UserActive and UserSuspended
- change database table to use status column instead of suspended
- update toggle suspended handler to be toggle status in prep for
possible future inclusion of further user statuses
2019-10-25 12:04:24 -07:00
Matt Baer 9873fc443f Merge branch 'develop' into T661-disable-accounts 2019-10-24 13:22:26 -04:00
Rob Loranger d954b7c8e3
add user invite instructions
this adds a new page with instructions for sharing user invites

if a user clicks the link for one of their own invite codes they are
directed to a page with clear instructions for it's use.

if a user clicks another users link they are redirectec to their account
settings witha flash telling them they do not need to register.
2019-09-13 10:58:17 -07:00
Matt Baer 40ffb3a5f9 Merge branch 'develop' into chorus 2019-09-10 21:41:28 +02:00
Matt Baer 9256293123
Merge pull request #169 from writeas/future-pins
prevent future posts from showing in pins
2019-09-10 21:37:28 +02:00
Matt Baer ca388d6536 Merge branch 'develop' into chorus 2019-09-09 17:26:40 +02:00
Rob Loranger 77f7b4a522
Add account suspension features
This renders all requests for that user's posts, collections and related
ActivityPub endpoints with 404 responses.

While suspended, users may not create or edit posts or collections.

User status is listed in the admin user page

Admin view of user details shows status and now has a button to activate
or suspend a user.
2019-08-29 09:09:11 -07:00
Rob Loranger 55dc1917fe
use established future posts pattern 2019-08-12 14:13:02 -07:00
Rob Loranger ca957c4b6d
fix missing collection hostname
GetCollections and GetPublishableCollections now take a hostname
parameter to allow setting the collecion hostname.

All collections used in memory now have their hostname set.
2019-08-12 12:35:17 -07:00
Rob Loranger b373aad298
prevent future posts from showing in pins
this changes GetPinnedPosts to accept an includeFutre bool, which
returns future dated pinned posts when true.
2019-08-12 09:58:30 -07:00
Matt Baer deec914ccb Merge branch 'develop' into chorus 2019-08-08 07:55:49 -04:00
Matt Baer adfcc82241
Merge pull request #148 from writeas/default-visibility
Support setting default blog visibility on instance

Resolves T675
2019-08-07 17:44:37 -04:00
Matt Baer f8d57d9e75 Return correct `public` state on collection creation
(in returned JSON data)

Ref T675
2019-08-07 16:22:35 -04:00
Matt Baer afadf6fdf6 Set default visibility in datastore.CreateCollection
instead of updating it later. This is more correct behavior, prevents an
additional query, and ensures that potential collection-creation when
claiming posts also respects the default (which it didn't before).

Ref T675
2019-08-07 16:20:32 -04:00
Matt Baer df078c569d Accept config.Config in datastore.CreateUser()
instead of App

Ref T675
2019-08-07 16:19:35 -04:00
Matt Baer 3cc397ad76 Merge branch 'develop' into chorus 2019-08-07 10:58:34 -04:00
Matt Baer ff7828c558 Link hashtags to Reader when Chorus mode enabled
instead of linking to posts only on a user's blog.

Ref T681
2019-08-07 09:40:07 -04:00
Matt Baer a75b45f060 Support configuring default collection visibility
This adds a new `default_visibility` config value that lets an instance
admin set the visibility of newly created collections.

Ref T675
2019-07-31 22:18:40 -04:00
Matt Baer f6f116d672 Fix missing hostname when publishing via API
This fixes a bug that occurred only when publishing via API and
authenticating via token (rather than cookie).

Previously, the instance's hostname wouldn't be added to the Collection
that got passed around after retrieving the owned post, meaning an
incomplete URL was returned in the API response, and federation failed due
to the missing host.
2019-07-22 14:02:53 -04:00
Matt Baer 909976dd90 Don't consider post unpublished when title exists
Previously, you could create a post with a title but no body, e.g. by
publishing via email. This would still show the post on a blog, but
would give a 410 Gone page when trying to access the page.

This issue originally reported on the forum:
https://discuss.write.as/t/removing-post-unpublished-by-author-post/725
2019-07-14 12:59:33 -04:00
Matt Baer 00a8f8c951
Merge pull request #119 from qwazix/develop
Half-fix of #96
2019-06-27 09:29:25 -04:00
Matt Baer a10a4e9a28 Merge branch 'develop' into librarization 2019-06-13 20:39:52 -04:00
Matt Baer 758269e3d8 Move key generation and Keychain to key pkg
Ref T613
2019-06-13 13:47:28 -04:00
Michael Demetriou 9570388d1d Fix #96
This solves the error 500 on the /api/me endpoint.

Replace token search query `=` with `LIKE` to fix sqlite complaining about
no valid tokens. Also checked with MySQL and it still works after the change.
2019-06-11 20:18:58 +03:00
Noëlle Anthony f271e53925 Update GetPosts() docstring 2019-05-29 12:03:01 -04:00
Noëlle Anthony 95e84a1d0e Change GetPosts() to have includePinned parameter, change all calls to match 2019-05-28 14:54:56 -04:00
Matt Baer 9e43b04f04 Make Keychain struct public 2019-05-12 17:20:24 -04:00
Matt Baer d8937e89a8 Make App struct public 2019-05-12 17:19:38 -04:00
Matt Baer 9cb0f80921 Support changing instance page titles
Now admins can choose a title for their About and Privacy pages; now
editable through the instance page editor.

This adds `title` and `content_type` fields to the `appcontent` table,
requiring a migration by running `writefreely --migrate`

The content_type field specifies that items we're currently storing in
this table are all "page"s; queries for fetching these have been updated
to filter for this type. In the future, this field will be used to
indicate when an item is a stylesheet (ref T563) or other supported
type.

Ref T566
2019-04-11 13:56:07 -04:00
Matt Baer a850fa14cd Move instance page editing to dedicated section
This adds a "Pages" section to the admin part of the site, and enables
admins to edit the pre-defined About and Privacy pages there, instead of
on the dashboard itself.

It also restructures how these pages get sent around in the backend and
lays the groundwork for dynamically adding static pages. The backend
changes were made with more customization in mind, such as an
instance-wide custom stylesheet (T563).

Ref T566
2019-04-06 13:23:22 -04:00
Matt Baer 372b4e5dcd Fix nil pointer when navigating to bad invite URL
Previously when looking up an invite ID that doesn't exist, the database
call wouldn't communicate its non-existence in a standard way --
returning a nil object and nil error. Now the database call returns a
404 error, so handlers can show the correct page.
2019-02-27 06:15:42 -05:00
Matt Baer 70e823d6ab Support user invites
This includes:

- A new `user_invites` config value that determines who can generate
  invite links
- A new page for generating invite links, with new user navigation link
- A new /invite/ path that allows anyone to sign up via unique invite
  link, even if registrations are closed
- Tracking who (of registered users) has been invited by whom

It requires an updated database with `writefreely --migrate` in order to
work.

This closes T556
2019-01-18 00:05:50 -05:00
Matt Baer 062ae0e16a Initialize db on single-user instance config
This fixes the --config step so that when setting up a single-user
instance for the first time (and creating the admin user as part of the
process), the database is automatically initialized before creating that
user.

This removes the need for the --init-db command after --config when
setting up single-user instances.

It fixes #59: "no such table: users" error during the --config step on
single-user instances that haven't previously run --init-db.
2019-01-13 09:08:47 -05:00
Matt Baer 8a555567a6 Fix tagged posts SQLite query
SQLite doesn't have an `RLIKE` function, so the query for hashtagged
posts was failing before. This adds a `regexp` function to SQLite and
correctly retrieves all posts on a blog with the requested hashtag.

This closes #55
2019-01-07 11:55:23 -05:00
Matt Baer 1c58c64c7c Fix SQLite deadlock when creating user
This avoids reading from the database after a transaction has been
started in CreateUser(), fixing the deadlock that occurred before.

Closes #53
2019-01-06 21:30:34 -05:00
Matt Baer bf7d422039 Add pager to admin user list
This enables paging through the entire list of users.

Ref T553
2019-01-05 09:37:53 -05:00
Matt Baer 3d301c97e9 Fix admin user paging query 2019-01-05 08:47:42 -05:00
Matt Baer 0e722de82c Add admin user list
This enables admins on multi-user instances to see all users registered,
and view the details of each, including:

- Username
- Join date
- Total posts
- Last post date
- All blogs
  - Public info
  - Views
  - Total posts
  - Last post date
  - Fediverse followers count

This is the foundation for future user moderation features.

Ref T553
2019-01-04 22:28:29 -05:00
Matt Baer fca3019e4b Support building without SQLite support
This adds a new `sqlite` build tag that you should include only if you
want SQLite3 support built in. Both `make run` and `make release` create
builds with SQLite included.
2019-01-03 17:57:06 -05:00
Matt Baer 3ae45bc156 Fix spacing around copyright notices 2018-12-31 01:05:26 -05:00
Matt Baer 1274914207 Add copyright / license notices to .go files 2018-12-24 12:45:15 -05:00
Matt Baer 25a68d0c0e Add Reader section
This adds a "Reader" section of the site for admins who want to enable
it for their instance. That means visitors can go to /read and see who
has publicly shared their writing. They can also follow all public posts
via RSS by going to /read/feed/. Writers on an instance with this
`local_timeline` setting enabled can publish to the timeline by going
into their blog settings and choosing the "Public" visibility setting.

The `local_timeline` feature is disabled by default, as is the Public
setting on writer blogs. Enabling it adds a "Reader" navigation item and
enables the reader endpoints. This feature will also consume more
memory, as public posts are cached in memory for 10 minutes.

These changes include code ported over from Read.Write.as, and thus
include some experimental features like filtering public posts by tags
and authors. These features aren't well-tested or complete.

Closes T554
2018-12-10 16:08:07 -05:00
Matt Baer c6851fee50 Fix duplicate key checks in SQLite
Ref T529
2018-12-08 13:25:20 -05:00
Matt Baer 4b780361bf Fix upsert queries on SQLite
Ref T529
2018-12-08 12:58:45 -05:00
Matt Baer 026604b3dd Fix pinned post content truncation with SQLite
This extracts the LEFT/SUBSTR logic into its own datastore.clip() method
that also works correctly with SQLite.

Ref T529
2018-12-08 12:54:49 -05:00
Matt Baer daaa4564bb Fix post `created` date in SQLite
We store times in UTC in all other places, but the post.Created logic
when creating a post meant that dates were being stored in a user's
local timezone. This fixes that.

Ref T529
2018-12-08 12:51:27 -05:00
Matt Baer 6f4c004e8c Fix SQLite date format string
The formatted string was invalid before, causing date parsing to fail.
This fixes that.

Ref T529
2018-12-08 12:28:52 -05:00
Matt Baer bc1b3fdfb7 Move NOW() calls to datastore.now() method
Ref T529
2018-12-08 12:15:16 -05:00