Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c426967
Update joined_communities_controller.rb
minkhantkyaw35 May 22, 2025
4efd23f
fix:collection of newsmast
minkhantkyaw35 May 22, 2025
176bcd3
[fix] text for newsmast
sithuthebo May 23, 2025
90c8891
Merge branch 'add_newsmast' into channels
sithuthebo May 23, 2025
fb8e050
modify migrate rake file
minkhantkyaw35 May 23, 2025
5124b9d
feat:app-versions
minkhantkyaw35 May 29, 2025
e832180
config database
minkhantkyaw35 May 30, 2025
3da4219
Merge branch 'feat-app-versions' into bk-main
minkhantkyaw35 May 30, 2025
65802d1
feat:application name
minkhantkyaw35 May 30, 2025
227537c
Update _form_step3.html.haml
minkhantkyaw35 May 30, 2025
deebecd
refactor: streamline channel filtering and collection handling
minkhantkyaw35 Jun 2, 2025
857d85b
Update collections_controller.rb
minkhantkyaw35 Jun 3, 2025
393cb29
refactor: enhance Sidekiq configuration for production and developmen…
minkhantkyaw35 Jun 4, 2025
752b99f
fix:sidekiq config
minkhantkyaw35 Jun 4, 2025
16dd377
Rollback sidekiq setting
minkhantkyaw35 Jun 4, 2025
90cd4cf
Just pass the password without encoding
kirankarki Jun 4, 2025
b50ba30
Lock and unlock to boost bot account
kirankarki Jun 10, 2025
7e9466e
Merge branch 'main' into channels
kirankarki Jun 10, 2025
87ae556
Update community_post_service.rb
minkhantkyaw35 Jun 10, 2025
74e5940
Merge branch 'main' into channels
minkhantkyaw35 Jun 10, 2025
b19b139
refactor: improve table column widths and structure
minkhantkyaw35 Jun 11, 2025
0c7e36b
Merge branch 'main' into channels
minkhantkyaw35 Jun 11, 2025
e2353ef
fix:null exception for bot
minkhantkyaw35 Jun 12, 2025
e692f67
Merge branch 'main' into channels
minkhantkyaw35 Jun 12, 2025
066b2fa
fix:duplication of name
minkhantkyaw35 Jun 12, 2025
0591c72
Update community.rb
minkhantkyaw35 Jun 12, 2025
5a12bef
Merge branch 'main' into channels
minkhantkyaw35 Jun 12, 2025
eed943c
fix:bluesky account
minkhantkyaw35 Jun 17, 2025
8cd102e
Merge branch 'main' into channels
minkhantkyaw35 Jun 17, 2025
ff024d4
Update bluesky_account_bridge_hleper.rb
minkhantkyaw35 Jun 17, 2025
1c5f33c
Merge branch 'main' into channels
minkhantkyaw35 Jun 17, 2025
daf539a
fix:organisation_admin login
minkhantkyaw35 Jun 17, 2025
49aa1fe
Merge branch 'main' into channels
minkhantkyaw35 Jun 17, 2025
634f946
feat:theme color
minkhantkyaw35 Jun 19, 2025
3f95e2f
fix: update environment variables
minkhantkyaw35 Jun 24, 2025
bff5bf1
Update the env file
kirankarki Jun 25, 2025
75b61c8
fix: update foreign key constraints for community rules
minkhantkyaw35 Jun 25, 2025
187c514
fix: update foreign key constraints for community rules
minkhantkyaw35 Jun 25, 2025
7230800
added: post's default visibility setting
eddie-nyan Jun 26, 2025
95295b2
Merge branch 'channels'
minkhantkyaw35 Jun 26, 2025
508c7af
add:foreign key to joined_communities
minkhantkyaw35 Jun 26, 2025
0765abd
fix: desc banner image, falsh msg on create admin
eddie-nyan Jun 30, 2025
5129bc2
fix: community info title
eddie-nyan Jun 30, 2025
a509de8
feat:Newsmast account migration
minkhantkyaw35 Jul 3, 2025
4cbbb7e
Update migrate_newsmast_channels.rake
minkhantkyaw35 Jul 4, 2025
1c27cc2
change userAdmin to NewsmastAdmin
minkhantkyaw35 Jul 4, 2025
41173ab
fix custom domain js error
minkhantkyaw35 Jul 5, 2025
58ca059
Update _form_step1.html.haml
minkhantkyaw35 Jul 5, 2025
1c9977a
enable continue
minkhantkyaw35 Jul 5, 2025
24fab11
feat:fetch bridged account info
minkhantkyaw35 Jul 7, 2025
5fb0765
feat:bridged account info
minkhantkyaw35 Jul 7, 2025
7530dae
Update sidekiq.yml
minkhantkyaw35 Jul 7, 2025
b907761
Update channels_controller.rb
minkhantkyaw35 Jul 7, 2025
0e5940c
Update sidekiq.yml
minkhantkyaw35 Jul 7, 2025
7c34ea5
Fix issue of underscore
kirankarki Jul 8, 2025
7f5b8b7
Add more logs
kirankarki Jul 8, 2025
8e0a5aa
Add updated csv file
kirankarki Jul 8, 2025
fa23eb2
Improve the script
kirankarki Jul 8, 2025
08a99f3
Add actual csv file
kirankarki Jul 8, 2025
6ec8fb0
Add whitelisted accounts
kirankarki Jul 8, 2025
bc135e0
Add more users
kirankarki Jul 8, 2025
22e69d6
Remove accounts
kirankarki Jul 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,53 @@ RAILS_ENV=development

# Redis
# Connect with your mastodon instance's redis
REDIS_HOST=localhost
REDIS_HOST=your_redis_host
REDIS_PORT=6379

# PostgreSQL
# Connect with your mastodon instance's database
DB_HOST=localhost
DB_HOST=your_postgres_host
DB_NAME=your_mastodon_instance_db
DB_USER=postgres
DB_PASS=db_pass
DB_USER=your_postgres_user
DB_PASS=your_postgres_password
DB_PORT=5432

PATCHWORK_HUB_URL=http://localhost:8000
MASTODON_INSTANCE_URL=http://localhost:3000
PATCHWORK_DASHBOARD_URL=http://localhost:8001
MASTODON_APPLICATION_TOKEN=GDtc2wQoxu8r7LBdrK26UecQAnSLtSOh5YPD5YRlZRc
MASTODON_CLIENT_ID=0umSVjLgczp7D6oIK6mA8OUjX2v28Zyi_63cXTbjLMU
MASTODON_CLIENT_SECRET=M2Lofni_76syqk7UkXGdd2KmFAksFmsT35ZMAgCdClA
# Patchwork Hub(central dashboard)
PATCHWORK_HUB_URL=https://hub.patchwork.online

CREATE_CHANNEL_LAMBDA_URL=https://lambda_url
CREATE_CHANNEL_LAMBDA_API_KEY=lambda_api_key
# Your hosted Patchwork Dashboard URL
PATCHWORK_DASHBOARD_URL=https://localhost:3001

# Mastodon Credentials
# Obtain these from your Mastodon instance under "Development" settings.
# Required scope: read, profile, write, follow, push
MASTODON_APPLICATION_TOKEN=your_mastodon_application_token
MASTODON_CLIENT_ID=yur_mastodon_client_id
MASTODON_CLIENT_SECRET=your_mastodon_client_secret
MASTODON_INSTANCE_URL=https://example.com

# Configure your SMTP settings for sending emails.
# You can use services like Amazon SES, SendGrid, or any SMTP server.
SMTP_LOGIN=your_smtp_login
SMTP_ENABLE_STARTTLS_AUTO=true
SMTP_AUTH_METHOD=plain
SMTP_DOMAIN=example.com
SMTP_PASSWORD=your_smtp_password
SMTP_FROM_ADDRESS=no-reply@example.com
SMTP_PORT=2587
SMTP_ENABLE_STARTTLS=auto
SMTP_SERVER=your_smtp_server

# S3 Configuration
# Configure your S3 bucket for file storage.
S3_REGION=your_s3_region
S3_BUCKET=example-bucket
S3_ALIAS_HOST=example-bucket.s3.eu-west-2.amazonaws.com
S3_ENABLED=false
S3_ACCESS_KEY_ID=your_s3_access_key_id

# Channel Creation
# Configure the channel creation settings.
ALLOW_CHANNELS_CREATION=false
CREATE_CHANNEL_LAMBDA_URL=https://example.com/create-channel
CREATE_CHANNEL_LAMBDA_API_KEY=lambda_api_key
52 changes: 35 additions & 17 deletions app/controllers/api/v1/app_versions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,46 @@ class AppVersionsController < ApiController
before_action :set_app_version, only: %i[check_version]

def check_version
return render_not_found unless @app_version

app_version_history = AppVersionHistory.where(
app_version_id: @app_version.id,
os_type: params[:os_type]
).last
app_version_history.present? ? render(json: { data: app_version_history }) : render_not_found
return render_error(message: 'Record not found!', status_code: 404) unless @app_version

unless app_version_params[:os_type].present?
return render_error(message: 'OS type is required', status_code: 400)
end

app_version_history = fetch_version_history
app_version_history.present? ? render(json: { data: app_version_history }) : render_error(message: 'Record not found!', status_code: 404)
end

private

def set_app_version
@app_version = AppVersion.find_by(version_name: params[:current_app_version])
end

def render_not_found
render json: { error: "Record not found" }, status: 404
end
def set_app_version
key = app_version_params[:app_name]&.to_sym || :patchwork
app_name = AppVersion.app_names[key] || AppVersion.app_names[:patchwork]
@app_version = AppVersion.find_by(
version_name: app_version_params[:current_app_version],
app_name: app_name
)
end

def render_error(message: "", status_code: 400)
render json: { error: message }, status: status_code
end

def app_version_params
params.permit(:current_app_version, :app_name, :os_type)
end

def check_authorization_header
authenticate_user_from_header if request.headers['Authorization'].present?
end

def fetch_version_history
@app_version.app_version_histories
.where(os_type: app_version_params[:os_type])
.order(created_at: :desc)
.first
end

def check_authorization_header
authenticate_user_from_header if request.headers['Authorization'].present?
end
end
end
end
12 changes: 12 additions & 0 deletions app/controllers/api/v1/channels_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ def newsmast_channels
end
end

def bridge_information
community = Community.find_by(id: params[:id])
if community.nil?
render json: { error: 'Community not found' }, status: :not_found and return
end
bluesky_info = BlueskyService.new(community).fetch_bluesky_account
render json: {
community: community,
bluesky_info: bluesky_info,
}
end

private

def set_channel
Expand Down
108 changes: 72 additions & 36 deletions app/controllers/api/v1/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,46 @@ class CollectionsController < ApiController
skip_before_action :verify_key!
before_action :fetch_channel_details, only: [:fetch_channels]

NEWSMAST_CHANNELS_SORTING_ORDERS = ['Newsmast Channels', 'News','Global Issues', 'Government & Politics', 'Environment', 'Communities & Allies', 'Business & Work', 'Technology', 'Science', 'Humanities', 'Culture', 'Sport', 'Lifestyle', ]
COLLECTION_TYPES = {
channel: 'channel',
channel_feed: 'channel_feed',
newsmast: 'newsmast'
}.freeze

NEWSMAST_CHANNELS_SORTING_ORDERS = [
'Newsmast Channels',
'News',
'Global Issues',
'Government & Politics',
'Environment',
'Communities & Allies',
'Business & Work',
'Technology',
'Science',
'Humanities',
'Culture',
'Sport',
'Lifestyle'
].freeze

def index
@all_collections = fetch_all_channels_by_type(type: 'channel')
render_collections(@all_collections, type: 'channel')
@all_collections = fetch_all_channels_by_type(type: COLLECTION_TYPES[:channel])
render_collections(@all_collections, type: COLLECTION_TYPES[:channel])
end

def newsmast_collections
patchwork_collection_ids = extract_patchwork_collection_ids
@all_collections = fetch_collections_by_ids(patchwork_collection_ids)

# Sort collections by NEWSMAST_CHANNELS_SORTING_ORDERS
@all_collections = @all_collections.sort_by do |collection|
NEWSMAST_CHANNELS_SORTING_ORDERS.index(collection.name) || Float::INFINITY
end

render_collections(@all_collections, type: 'newsmast')
def channel_feed_collections
@all_collections = fetch_all_channels_by_type(type: COLLECTION_TYPES[:channel_feed])
render_collections(@all_collections, type: COLLECTION_TYPES[:channel_feed])
end

def channel_feed_collections
@all_collections = fetch_all_channels_by_type(type: 'channel_feed')
render_collections(@all_collections, type: 'channel_feed')
def newsmast_collections
@all_collections = fetch_all_channels_by_type(type: COLLECTION_TYPES[:newsmast])
render_collections(@all_collections, type: COLLECTION_TYPES[:newsmast])
end

def fetch_channels
if @channels
render json: serialized_channels(@channels,type: params[:type])
render json: serialized_channels(type: params[:type])
else
render json: { data: [] }
end
Expand All @@ -41,10 +54,22 @@ def fetch_channels
private

def fetch_all_channels_by_type(type:)
collections = if type == 'channel'
Collection.filter_channels.distinct.order(sorting_index: :asc).to_a
collections = case type
when COLLECTION_TYPES[:channel]
Collection.filter_by_channel_type(type).order(sorting_index: :asc).to_a
when COLLECTION_TYPES[:channel_feed]
Collection.filter_by_channel_type(type).order(sorting_index: :asc).to_a
else
Collection.filter_channel_feeds.distinct.order(sorting_index: :asc).to_a
newsmast_collections = if Community.has_local_newsmast_channel?
Collection.filter_by_channel_type(type).order(sorting_index: :asc).to_a
else
patchwork_collection_ids = extract_patchwork_collection_ids
fetch_collections_by_ids(patchwork_collection_ids)
end
newsmast_collections = newsmast_collections.sort_by do |collection|
NEWSMAST_CHANNELS_SORTING_ORDERS.index(collection.name) || Float::INFINITY
end
newsmast_collections
end
add_all_collection(collections, type: type)
end
Expand All @@ -56,8 +81,7 @@ def extract_patchwork_collection_ids
end

def fetch_collections_by_ids(ids)
collections = Collection.where(id: ids).order(sorting_index: :asc).to_a
add_all_collection(collections, type: 'newsmast')
Collection.where(id: ids).order(sorting_index: :asc).to_a
end

def render_collections(collections, type:)
Expand All @@ -66,22 +90,29 @@ def render_collections(collections, type:)
).serializable_hash.to_json
end

def serialized_channels(channels, type:)
if type == 'channel' || type == 'channel_feed'
Api::V1::ChannelSerializer.new(channels).serializable_hash.to_json
def serialized_channels(type:)
if type == COLLECTION_TYPES[:channel] || type == COLLECTION_TYPES[:channel_feed]
Api::V1::ChannelSerializer.new(@channels).serializable_hash.to_json
else
channels
if Community.has_local_newsmast_channel? && params[:type] == COLLECTION_TYPES[:newsmast]
data = Api::V1::ChannelSerializer.new(@channels).serializable_hash.to_json
# Need to remove after mobile lunch again
parsed = JSON.parse(data)
parsed["data"]
else
@channels
end
end
end

def fetch_channel_details
return unless params[:slug].present? && params[:type].present?

@channels = if params[:type] == 'newsmast'
fetch_newsmast_channels
else
fetch_communities(type: params[:type])
end
@channels = if !Community.has_local_newsmast_channel? && params[:type] == COLLECTION_TYPES[:newsmast]
fetch_newsmast_channels
else
fetch_communities(type: params[:type])
end
end

def fetch_newsmast_channels
Expand All @@ -105,8 +136,13 @@ def fetch_communities(type:)
end
return [] unless base_communities

scope = type == 'channel' ? :filter_channels : :filter_channel_feeds

scope = if type == COLLECTION_TYPES[:channel]
:filter_channels
elsif type == COLLECTION_TYPES[:channel_feed]
:filter_channel_feeds
else
:filter_newsmast_channels
end
base_communities
.public_send(scope)
.exclude_array_ids
Expand All @@ -117,9 +153,9 @@ def fetch_communities(type:)

def add_all_collection(collections, type:)
name = case type
when 'channel'
when COLLECTION_TYPES[:channel]
'Communities'
when 'channel_feed'
when COLLECTION_TYPES[:channel_feed]
'Channels'
else
'Newsmast Channels'
Expand All @@ -138,4 +174,4 @@ def add_all_collection(collections, type:)
end
end
end
end
end
1 change: 1 addition & 0 deletions app/controllers/api/v1/communities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class CommunitiesController < ApiController
before_action :set_community, only: %i[show update set_visibility manage_additional_information]
before_action :validate_patchwork_community_id, only: %i[contributor_list mute_contributor_list]
before_action :set_content_and_channel_type, only: %i[index create update]
include BlueskyAccountBridgeHleper
PER_PAGE = 5

def index
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/joined_communities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def set_primary
return render json: { errors: 'Community not found' }, status: 404
end

if @account.joined_communities.size < 6
if @account.joined_communities.size < 4
return render json: { errors: 'You need to join at least 5 to set as primary' }, status: 422
end

Expand Down
Loading