repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/helpers/users/filter_helper.rb | app/helpers/users/filter_helper.rb | module Users::FilterHelper
def user_filter_menu_tag(&)
tag.menu class: "flex flex-column gap margin-none pad overflow-y constrain-height",
data: { controller: "filter", filter_active_class: "filter--active", filter_selected_class: "selected" }, &
end
def user_filter_search_tag
tag.input type: "sear... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/helpers/content_filters/remove_solo_unfurled_link_text.rb | app/helpers/content_filters/remove_solo_unfurled_link_text.rb | class ContentFilters::RemoveSoloUnfurledLinkText < ActionText::Content::Filter
def applicable?
normalize_tweet_url(solo_unfurled_url) == normalize_tweet_url(content.to_plain_text)
end
def apply
fragment.replace("div") { |node| node.tap { |n| n.inner_html = unfurled_links.first.to_s } }
end
private
... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/helpers/content_filters/style_unfurled_twitter_avatars.rb | app/helpers/content_filters/style_unfurled_twitter_avatars.rb | class ContentFilters::StyleUnfurledTwitterAvatars < ActionText::Content::Filter
def applicable?
unfurled_twitter_avatars.present?
end
def apply
fragment.update do |source|
div = source.at_css("div")
div["class"] = UNFURLED_TWITTER_AVATAR_CSS_CLASS
end
end
private
UNFURLED_TWITTER... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/helpers/content_filters/sanitize_tags.rb | app/helpers/content_filters/sanitize_tags.rb | class ContentFilters::SanitizeTags < ActionText::Content::Filter
def applicable?
true
end
def apply
fragment.replace(not_allowed_tags_css_selector) { nil }
end
private
ALLOWED_TAGS = %w[ a abbr acronym address b big blockquote br cite code dd del dfn div dl dt em h1 h2 h3 h4 h5 h6 hr i ins kbd l... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/qr_code_controller.rb | app/controllers/qr_code_controller.rb | class QrCodeController < ApplicationController
allow_unauthenticated_access
def show
url = Base64.urlsafe_decode64(params[:id])
qr_code = RQRCode::QRCode.new(url).as_svg(viewbox: true, fill: :white, color: :black)
expires_in 1.year, public: true
render plain: qr_code, content_type: "image/svg+xml"... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/searches_controller.rb | app/controllers/searches_controller.rb | class SearchesController < ApplicationController
before_action :set_messages
def index
@query = query if query.present?
@recent_searches = Current.user.searches.ordered
@return_to_room = last_room_visited
end
def create
Current.user.searches.record(query)
redirect_to searches_url(q: query)... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/unfurl_links_controller.rb | app/controllers/unfurl_links_controller.rb | class UnfurlLinksController < ApplicationController
def create
opengraph = Opengraph::Metadata.from_url(url_param)
if opengraph.valid?
render json: opengraph
else
head :no_content
end
end
private
def url_param
params.require(:url)
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/welcome_controller.rb | app/controllers/welcome_controller.rb | class WelcomeController < ApplicationController
def show
if Current.user.rooms.any?
redirect_to room_url(last_room_visited)
else
render
end
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/rooms_controller.rb | app/controllers/rooms_controller.rb | class RoomsController < ApplicationController
before_action :set_room, only: %i[ show destroy ]
before_action :ensure_can_administer, only: %i[ destroy ]
before_action :remember_last_room_visited, only: :show
def index
redirect_to room_url(Current.user.rooms.last)
end
def show
@messages = find_mes... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/users_controller.rb | app/controllers/users_controller.rb | class UsersController < ApplicationController
require_unauthenticated_access only: %i[ new create ]
before_action :set_user, only: :show
before_action :verify_join_code, only: %i[ new create ]
def new
@user = User.new
end
def create
@user = User.create!(user_params)
start_new_session_for @use... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/pwa_controller.rb | app/controllers/pwa_controller.rb | class PwaController < ApplicationController
allow_unauthenticated_access
skip_forgery_protection
# We need a stable URL at the root, so we can't use the regular asset path here.
def service_worker
end
# Need ERB interpolation for paths, so can't use asset path here either.
def manifest
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/messages_controller.rb | app/controllers/messages_controller.rb | class MessagesController < ApplicationController
include ActiveStorage::SetCurrent, RoomScoped
before_action :set_room, except: :create
before_action :set_message, only: %i[ show edit update destroy ]
before_action :ensure_can_administer, only: %i[ edit update destroy ]
layout false, only: :index
def ind... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/first_runs_controller.rb | app/controllers/first_runs_controller.rb | class FirstRunsController < ApplicationController
allow_unauthenticated_access
before_action :prevent_repeats
def show
@user = User.new
end
def create
user = FirstRun.create!(user_params)
start_new_session_for user
redirect_to root_url
rescue ActiveRecord::RecordNotUnique
redirect_to... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/sessions_controller.rb | app/controllers/sessions_controller.rb | class SessionsController < ApplicationController
allow_unauthenticated_access only: %i[ new create ]
rate_limit to: 10, within: 3.minutes, only: :create, with: -> { render_rejection :too_many_requests }
before_action :ensure_user_exists, only: :new
def new
end
def create
if user = User.active.authent... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/application_controller.rb | app/controllers/application_controller.rb | class ApplicationController < ActionController::Base
include AllowBrowser, Authentication, Authorization, BlockBannedRequests, SetCurrentRequest, SetPlatform, TrackedRoomVisit, VersionHeaders
include Turbo::Streams::Broadcasts, Turbo::Streams::StreamName
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/accounts_controller.rb | app/controllers/accounts_controller.rb | class AccountsController < ApplicationController
before_action :ensure_can_administer, only: :update
before_action :set_account
def edit
users = account_users.ordered.without_bots
@administrators, @members = users.partition(&:administrator?)
set_page_and_extract_portion_from users, per_page: 500
en... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/concerns/authentication.rb | app/controllers/concerns/authentication.rb | module Authentication
extend ActiveSupport::Concern
include SessionLookup
included do
before_action :require_authentication
before_action :deny_bots
helper_method :signed_in?
protect_from_forgery with: :exception, unless: -> { authenticated_by.bot_key? }
end
class_methods do
def allow_u... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/concerns/set_platform.rb | app/controllers/concerns/set_platform.rb | module SetPlatform
extend ActiveSupport::Concern
included do
helper_method :platform
end
private
def platform
@platform ||= ApplicationPlatform.new(request.user_agent)
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/concerns/set_current_request.rb | app/controllers/concerns/set_current_request.rb | module SetCurrentRequest
extend ActiveSupport::Concern
included do
before_action do
Current.request = request
end
end
def default_url_options
{ host: Current.request_host, protocol: Current.request_protocol }.compact_blank
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/concerns/allow_browser.rb | app/controllers/concerns/allow_browser.rb | module AllowBrowser
extend ActiveSupport::Concern
VERSIONS = { safari: 17.2, chrome: 120, firefox: 121, opera: 104, ie: false }
included do
allow_browser versions: VERSIONS, block: -> { render template: "sessions/incompatible_browser" }
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/concerns/version_headers.rb | app/controllers/concerns/version_headers.rb | module VersionHeaders
extend ActiveSupport::Concern
included do
before_action :set_version_headers
end
private
def set_version_headers
response.headers["X-Version"] = Rails.application.config.app_version
response.headers["X-Rev"] = Rails.application.config.git_revision
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/concerns/tracked_room_visit.rb | app/controllers/concerns/tracked_room_visit.rb | module TrackedRoomVisit
extend ActiveSupport::Concern
included do
helper_method :last_room_visited
end
def remember_last_room_visited
cookies.permanent[:last_room] = @room.id
end
def last_room_visited
Current.user.rooms.find_by(id: cookies[:last_room]) || default_room
end
private
def... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/concerns/room_scoped.rb | app/controllers/concerns/room_scoped.rb | module RoomScoped
extend ActiveSupport::Concern
included do
before_action :set_room
end
private
def set_room
@membership = Current.user.memberships.find_by!(room_id: params[:room_id])
@room = @membership.room
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/concerns/block_banned_requests.rb | app/controllers/concerns/block_banned_requests.rb | module BlockBannedRequests
extend ActiveSupport::Concern
included do
before_action :reject_banned_ip, unless: :safe_request?
end
private
def reject_banned_ip
head :too_many_requests if Ban.banned?(request.remote_ip)
end
def safe_request?
request.get? || request.head?
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/concerns/authorization.rb | app/controllers/concerns/authorization.rb | module Authorization
private
def ensure_can_administer
head :forbidden unless Current.user.can_administer?
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/concerns/authentication/session_lookup.rb | app/controllers/concerns/authentication/session_lookup.rb | module Authentication::SessionLookup
def find_session_by_cookie
if token = cookies.signed[:session_token]
Session.find_by(token: token)
end
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/rooms/closeds_controller.rb | app/controllers/rooms/closeds_controller.rb | class Rooms::ClosedsController < RoomsController
before_action :set_room, only: %i[ show edit update ]
before_action :ensure_can_administer, only: %i[ update ]
before_action :remember_last_room_visited, only: :show
before_action :force_room_type, only: %i[ edit update ]
before_action :ensure_permission_to_cre... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/rooms/opens_controller.rb | app/controllers/rooms/opens_controller.rb | class Rooms::OpensController < RoomsController
before_action :set_room, only: %i[ show edit update ]
before_action :ensure_can_administer, only: %i[ update ]
before_action :remember_last_room_visited, only: :show
before_action :force_room_type, only: %i[ edit update ]
before_action :ensure_permission_to_creat... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/rooms/directs_controller.rb | app/controllers/rooms/directs_controller.rb | class Rooms::DirectsController < RoomsController
before_action :set_room, only: %i[ edit destroy ]
def new
@room = Rooms::Direct.new
end
def create
room = Rooms::Direct.find_or_create_for(selected_users)
broadcast_create_room(room)
redirect_to room_url(room)
end
def edit
end
private
... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/rooms/involvements_controller.rb | app/controllers/rooms/involvements_controller.rb | class Rooms::InvolvementsController < ApplicationController
include RoomScoped
def show
@involvement = @membership.involvement
end
def update
@membership.update! involvement: params[:involvement]
broadcast_visibility_changes
redirect_to room_involvement_url(@room)
end
private
def bro... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/rooms/refreshes_controller.rb | app/controllers/rooms/refreshes_controller.rb | class Rooms::RefreshesController < ApplicationController
include RoomScoped
before_action :set_last_updated_at
def show
@new_messages = @room.messages.with_creator.page_created_since(@last_updated_at)
@updated_messages = @room.messages.without(@new_messages).with_creator.page_updated_since(@last_updated... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/messages/boosts_controller.rb | app/controllers/messages/boosts_controller.rb | class Messages::BoostsController < ApplicationController
before_action :set_message
def index
end
def new
end
def create
@boost = @message.boosts.create!(boost_params)
broadcast_create
redirect_to message_boosts_url(@message)
end
def destroy
@boost = Current.user.boosts.find(params[... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/messages/by_bots_controller.rb | app/controllers/messages/by_bots_controller.rb | class Messages::ByBotsController < MessagesController
allow_bot_access only: :create
def create
super
head :created, location: message_url(@message)
end
private
def message_params
if params[:attachment]
params.permit(:attachment)
else
reading(request.body) { |body| { bo... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/autocompletable/users_controller.rb | app/controllers/autocompletable/users_controller.rb | class Autocompletable::UsersController < ApplicationController
def index
set_page_and_extract_portion_from find_autocompletable_users.with_attached_avatar.ordered, per_page: 20
end
private
def find_autocompletable_users
params[:query].present? ? users_scope.active.filtered_by(params[:query]) : user... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/sessions/transfers_controller.rb | app/controllers/sessions/transfers_controller.rb | class Sessions::TransfersController < ApplicationController
allow_unauthenticated_access
def show
end
def update
if user = User.active.find_by_transfer_id(params[:id])
start_new_session_for user
redirect_to post_authenticating_url
else
head :bad_request
end
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/accounts/users_controller.rb | app/controllers/accounts/users_controller.rb | class Accounts::UsersController < ApplicationController
before_action :ensure_can_administer, :set_user, only: %i[ update destroy ]
def index
set_page_and_extract_portion_from User.active.ordered.without_bots, per_page: 500
end
def update
@user.update(role_params)
redirect_to edit_account_url
en... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/accounts/join_codes_controller.rb | app/controllers/accounts/join_codes_controller.rb | class Accounts::JoinCodesController < ApplicationController
before_action :ensure_can_administer
def create
Current.account.reset_join_code
redirect_to edit_account_url
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/accounts/bots_controller.rb | app/controllers/accounts/bots_controller.rb | class Accounts::BotsController < ApplicationController
before_action :ensure_can_administer
before_action :set_bot, only: %i[ edit update destroy ]
def index
@bots = User.active_bots.ordered
end
def new
@bot = User.active_bots.new
end
def create
User.create_bot! bot_params
redirect_to a... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/accounts/custom_styles_controller.rb | app/controllers/accounts/custom_styles_controller.rb | class Accounts::CustomStylesController < ApplicationController
before_action :ensure_can_administer, :set_account
def edit
end
def update
@account.update!(account_params)
redirect_to edit_account_custom_styles_url, notice: "✓"
end
private
def set_account
@account = Current.account
e... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/accounts/logos_controller.rb | app/controllers/accounts/logos_controller.rb | class Accounts::LogosController < ApplicationController
include ActiveStorage::Streaming, ActionView::Helpers::AssetUrlHelper
allow_unauthenticated_access only: :show
before_action :ensure_can_administer, only: :destroy
def show
if stale?(etag: Current.account)
expires_in 5.minutes, public: true, st... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/accounts/bots/keys_controller.rb | app/controllers/accounts/bots/keys_controller.rb | class Accounts::Bots::KeysController < ApplicationController
before_action :ensure_can_administer
def update
User.active_bots.find(params[:bot_id]).reset_bot_key
redirect_to account_bots_url
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/users/sidebars_controller.rb | app/controllers/users/sidebars_controller.rb | class Users::SidebarsController < ApplicationController
DIRECT_PLACEHOLDERS = 20
def show
all_memberships = Current.user.memberships.visible.with_ordered_room
@direct_memberships = extract_direct_memberships(all_memberships)
@other_memberships = all_memberships.without(@direct_memberships)
@d... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/users/profiles_controller.rb | app/controllers/users/profiles_controller.rb | class Users::ProfilesController < ApplicationController
before_action :set_user
def show
@direct_memberships, @shared_memberships =
Current.user.memberships.with_ordered_room.partition { |m| m.room.direct? }
end
def update
@user.update user_params
redirect_to user_profile_url, notice: update... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/users/avatars_controller.rb | app/controllers/users/avatars_controller.rb | class Users::AvatarsController < ApplicationController
include ActiveStorage::Streaming
rescue_from(ActiveSupport::MessageVerifier::InvalidSignature) { head :not_found }
def show
@user = User.from_avatar_token(params[:user_id])
if stale?(etag: @user)
expires_in 30.minutes, public: true, stale_whi... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/users/bans_controller.rb | app/controllers/users/bans_controller.rb | class Users::BansController < ApplicationController
before_action :ensure_can_administer
before_action :set_user
def create
@user.ban
redirect_to @user
end
def destroy
@user.unban
redirect_to @user
end
private
def set_user
@user = User.find(params[:user_id])
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/users/push_subscriptions_controller.rb | app/controllers/users/push_subscriptions_controller.rb | class Users::PushSubscriptionsController < ApplicationController
before_action :set_push_subscriptions
def index
end
def create
if subscription = @push_subscriptions.find_by(push_subscription_params)
subscription.touch
else
@push_subscriptions.create! push_subscription_params.merge(user_ag... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/controllers/users/push_subscriptions/test_notifications_controller.rb | app/controllers/users/push_subscriptions/test_notifications_controller.rb | class Users::PushSubscriptions::TestNotificationsController < ApplicationController
before_action :set_push_subscription
def create
@push_subscription.notification(title: "Campfire Test", body: Random.uuid, path: user_push_subscriptions_url).deliver
redirect_to user_push_subscriptions_url
end
private
... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/current.rb | app/models/current.rb | class Current < ActiveSupport::CurrentAttributes
attribute :user, :request
delegate :host, :protocol, to: :request, prefix: true, allow_nil: true
def account
Account.first
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/session.rb | app/models/session.rb | class Session < ApplicationRecord
ACTIVITY_REFRESH_RATE = 1.hour
has_secure_token
belongs_to :user
before_create { self.last_active_at ||= Time.now }
def self.start!(user_agent:, ip_address:)
create! user_agent: user_agent, ip_address: ip_address
end
def resume(user_agent:, ip_address:)
if la... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/membership.rb | app/models/membership.rb | class Membership < ApplicationRecord
include Connectable
belongs_to :room
belongs_to :user
after_destroy_commit { user.reset_remote_connections }
enum :involvement, %w[ invisible nothing mentions everything ].index_by(&:itself), prefix: :involved_in
scope :with_ordered_room, -> { includes(:room).joins(:... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/account.rb | app/models/account.rb | class Account < ApplicationRecord
include Joinable
has_one_attached :logo
has_json :settings, restrict_room_creation_to_administrators: false
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/first_run.rb | app/models/first_run.rb | class FirstRun
ACCOUNT_NAME = "Campfire"
FIRST_ROOM_NAME = "All Talk"
def self.create!(user_params)
account = Account.create!(name: ACCOUNT_NAME)
room = Rooms::Open.new(name: FIRST_ROOM_NAME)
administrator = room.creator = User.new(user_params.merge(role: :administrator))
room.save!
room... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/sound.rb | app/models/sound.rb | class Sound
class Image < Struct.new(:asset_path, :width, :height)
def initialize(name:, width:, height:)
super "sounds/#{name}", width, height
end
end
def self.find_by_name(name)
INDEX[name]
end
def self.names
INDEX.keys.sort
end
attr_reader :name, :asset_path, :image, :text
d... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/room.rb | app/models/room.rb | class Room < ApplicationRecord
has_many :memberships, dependent: :delete_all do
def grant_to(users)
room = proxy_association.owner
Membership.insert_all(Array(users).collect { |user| { room_id: room.id, user_id: user.id, involvement: room.default_involvement } })
end
def revoke_from(users)
... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/boost.rb | app/models/boost.rb | class Boost < ApplicationRecord
belongs_to :message, touch: true
belongs_to :booster, class_name: "User", default: -> { Current.user }
scope :ordered, -> { order(:created_at) }
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/search.rb | app/models/search.rb | class Search < ApplicationRecord
belongs_to :user
after_create :trim_recent_searches
scope :ordered, -> { order(updated_at: :desc) }
class << self
def record(query)
find_or_create_by(query: query).touch
end
end
private
def trim_recent_searches
user.searches.excluding(user.searche... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/message.rb | app/models/message.rb | class Message < ApplicationRecord
include Attachment, Broadcasts, Mentionee, Pagination, Searchable
belongs_to :room, touch: true
belongs_to :creator, class_name: "User", default: -> { Current.user }
has_many :boosts, dependent: :destroy
has_rich_text :body
before_create -> { self.client_message_id ||= ... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/application_record.rb | app/models/application_record.rb | class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/push.rb | app/models/push.rb | module Push
def self.table_name_prefix
"push_"
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/application_platform.rb | app/models/application_platform.rb | class ApplicationPlatform < PlatformAgent
def ios?
match? /iPhone|iPad/
end
def android?
match? /Android/
end
def mac?
match? /Macintosh/
end
def chrome?
user_agent.browser.match? /Chrome/
end
def firefox?
user_agent.browser.match? /Firefox|FxiOS/
end
def safari?
user_... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/purchaser.rb | app/models/purchaser.rb | class Purchaser
def initialize
load_configuration
end
def registered?
@purchased_by.present?
end
def name
@purchased_by["name"] if registered?
end
private
def load_configuration
path = Rails.root.join("config/purchased_by.yml")
@purchased_by = YAML.load_file(path) if path.ex... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/ban.rb | app/models/ban.rb | class Ban < ApplicationRecord
belongs_to :user
validate :ip_address_is_public
def self.banned?(ip_address)
exists?(ip_address: ip_address)
end
private
def ip_address_is_public
ip = IPAddr.new(ip_address)
if ip.loopback? || ip.private? || ip.link_local?
errors.add(:ip_address, "... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/webhook.rb | app/models/webhook.rb | require "net/http"
require "uri"
class Webhook < ApplicationRecord
ENDPOINT_TIMEOUT = 7.seconds
belongs_to :user
def deliver(message)
post(payload(message)).tap do |response|
if text = extract_text_from(response)
receive_text_reply_to(message.room, text: text)
elsif attachment = extract... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/user.rb | app/models/user.rb | class User < ApplicationRecord
include Avatar, Bannable, Bot, Mentionable, Role, Transferable
has_many :memberships, dependent: :delete_all
has_many :rooms, through: :memberships
has_many :reachable_messages, through: :rooms, source: :messages
has_many :messages, dependent: :destroy, foreign_key: :creator_i... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/push/subscription.rb | app/models/push/subscription.rb | class Push::Subscription < ApplicationRecord
belongs_to :user
def notification(**params)
WebPush::Notification.new(**params, badge: user.memberships.unread.count, endpoint: endpoint, p256dh_key: p256dh_key, auth_key: auth_key)
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/room/message_pusher.rb | app/models/room/message_pusher.rb | class Room::MessagePusher
attr_reader :room, :message
def initialize(room:, message:)
@room, @message = room, message
end
def push
build_payload.tap do |payload|
push_to_users_involved_in_everything(payload)
push_to_users_involved_in_mentions(payload)
end
end
private
def build... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/user/bannable.rb | app/models/user/bannable.rb | module User::Bannable
extend ActiveSupport::Concern
def ban
transaction do
create_bans_from_sessions
apply_ban
banned!
end
end
def unban
transaction do
bans.delete_all
active!
end
end
def remove_banned_content_later
RemoveBannedContentJob.perform_later(se... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/user/bot.rb | app/models/user/bot.rb | module User::Bot
extend ActiveSupport::Concern
included do
scope :active_bots, -> { active.where(role: :bot) }
scope :without_bots, -> { where.not(role: :bot) }
has_one :webhook, dependent: :delete
end
module ClassMethods
def create_bot!(attributes)
bot_token = generate_bot_token
w... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/user/avatar.rb | app/models/user/avatar.rb | module User::Avatar
extend ActiveSupport::Concern
included do
has_one_attached :avatar
end
class_methods do
def from_avatar_token(sid)
find_signed!(sid, purpose: :avatar)
end
end
def avatar_token
signed_id(purpose: :avatar)
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/user/mentionable.rb | app/models/user/mentionable.rb | module User::Mentionable
include ActionText::Attachable
def to_attachable_partial_path
"users/mention"
end
def to_trix_content_attachment_partial_path
"users/mention"
end
def attachable_plain_text_representation(caption)
"@#{name}"
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/user/role.rb | app/models/user/role.rb | module User::Role
extend ActiveSupport::Concern
included do
enum :role, %i[ member administrator bot ]
end
def can_administer?(record = nil)
administrator? || self == record&.creator || record&.new_record?
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/user/transferable.rb | app/models/user/transferable.rb | module User::Transferable
extend ActiveSupport::Concern
TRANSFER_LINK_EXPIRY_DURATION = 4.hours
class_methods do
def find_by_transfer_id(id)
find_signed(id, purpose: :transfer)
end
end
def transfer_id
signed_id(purpose: :transfer, expires_in: TRANSFER_LINK_EXPIRY_DURATION)
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/membership/connectable.rb | app/models/membership/connectable.rb | module Membership::Connectable
extend ActiveSupport::Concern
CONNECTION_TTL = 60.seconds
included do
scope :connected, -> { where(connected_at: CONNECTION_TTL.ago..) }
scope :disconnected, -> { where(connected_at: [ nil, ...CONNECTION_TTL.ago ]) }
end
class_methods do
def disconnect_all
... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/rooms/direct.rb | app/models/rooms/direct.rb | # Rooms for direct message chats between users. These act as a singleton, so a single set of users will
# always refer to the same direct room.
class Rooms::Direct < Room
class << self
def find_or_create_for(users)
find_for(users) || create_for({}, users: users)
end
private
# FIXME: Find a mo... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/rooms/closed.rb | app/models/rooms/closed.rb | # Rooms where only a subset of all users on the account have been explicited granted membership.
class Rooms::Closed < Room
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/rooms/open.rb | app/models/rooms/open.rb | # Rooms open to all users on the account. When a new user is added to the account, they're automatically granted membership.
class Rooms::Open < Room
after_save_commit :grant_access_to_all_users
private
def grant_access_to_all_users
memberships.grant_to(User.active) if type_previously_changed?(to: "Rooms... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/account/joinable.rb | app/models/account/joinable.rb | module Account::Joinable
extend ActiveSupport::Concern
included do
before_create { self.join_code = generate_join_code }
end
def reset_join_code
update! join_code: generate_join_code
end
private
def generate_join_code
SecureRandom.alphanumeric(12).scan(/.{4}/).join("-")
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/opengraph/location.rb | app/models/opengraph/location.rb | require "restricted_http/private_network_guard"
class Opengraph::Location
include ActiveModel::Validations
attr_accessor :url, :parsed_url
validate :validate_url, :validate_url_is_public
def initialize(url)
@url = url
end
def read_html
fetch_html if valid? && !url.match(FILES_AND_MEDIA_URL_REGE... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/opengraph/fetch.rb | app/models/opengraph/fetch.rb | require "net/http"
require "restricted_http/private_network_guard"
class Opengraph::Fetch
ALLOWED_DOCUMENT_CONTENT_TYPE = "text/html"
MAX_BODY_SIZE = 5.megabytes
MAX_REDIRECTS = 10
class TooManyRedirectsError < StandardError; end
class RedirectDeniedError < StandardError; end
def fetch_document(url, ip: ... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/opengraph/document.rb | app/models/opengraph/document.rb | require "nokogiri"
class Opengraph::Document
attr_accessor :html
def initialize(html)
@html = Nokogiri::HTML(html)
end
def opengraph_attributes
@opengraph_attributes ||= extract_opengraph_attributes
end
private
def extract_opengraph_attributes
opengraph_tags = html.xpath("//*/meta[star... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/opengraph/metadata.rb | app/models/opengraph/metadata.rb | class Opengraph::Metadata
include ActiveModel::Model
include ActiveModel::Validations::Callbacks
include ActionView::Helpers::SanitizeHelper
include Fetching
ATTRIBUTES = %i[ title url image description ]
attr_accessor *ATTRIBUTES
before_validation :sanitize_fields
validates_presence_of :title, :url... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/opengraph/metadata/fetching.rb | app/models/opengraph/metadata/fetching.rb | module Opengraph::Metadata::Fetching
extend ActiveSupport::Concern
module ClassMethods
def from_url(url)
document = fetch_document(url)
attributes = document.opengraph_attributes
new attributes.merge(url: valid_canonical_url(attributes[:url], url), image: valid_image_content_type(attributes[:... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/message/searchable.rb | app/models/message/searchable.rb | module Message::Searchable
extend ActiveSupport::Concern
included do
after_create_commit :create_in_index
after_update_commit :update_in_index
after_destroy_commit :remove_from_index
scope :search, ->(query) { joins("join message_search_index idx on messages.id = idx.rowid").where("idx.body matc... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/message/pagination.rb | app/models/message/pagination.rb | module Message::Pagination
extend ActiveSupport::Concern
PAGE_SIZE = 40
included do
scope :last_page, -> { ordered.last(PAGE_SIZE) }
scope :first_page, -> { ordered.first(PAGE_SIZE) }
scope :before, ->(message) { where("created_at < ?", message.created_at) }
scope :after, ->(message) { where("c... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/message/broadcasts.rb | app/models/message/broadcasts.rb | module Message::Broadcasts
def broadcast_create
broadcast_append_to room, :messages, target: [ room, :messages ]
ActionCable.server.broadcast("unread_rooms", { roomId: room.id })
end
def broadcast_remove
broadcast_remove_to room, :messages
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/message/attachment.rb | app/models/message/attachment.rb | module Message::Attachment
extend ActiveSupport::Concern
THUMBNAIL_MAX_WIDTH = 1200
THUMBNAIL_MAX_HEIGHT = 800
included do
has_one_attached :attachment do |attachable|
attachable.variant :thumb, resize_to_limit: [ THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT ]
end
end
module ClassMethods
d... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/models/message/mentionee.rb | app/models/message/mentionee.rb | module Message::Mentionee
extend ActiveSupport::Concern
def mentionees
room.users.where(id: mentioned_users.map(&:id))
end
private
def mentioned_users
if body.body
body.body.attachables.grep(User).uniq
else
[]
end
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/channels/read_rooms_channel.rb | app/channels/read_rooms_channel.rb | class ReadRoomsChannel < ApplicationCable::Channel
def subscribed
stream_from "user_#{current_user.id}_reads"
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/channels/unread_rooms_channel.rb | app/channels/unread_rooms_channel.rb | class UnreadRoomsChannel < ApplicationCable::Channel
def subscribed
stream_from "unread_rooms"
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/channels/presence_channel.rb | app/channels/presence_channel.rb | class PresenceChannel < RoomChannel
on_subscribe :present, unless: :subscription_rejected?
on_unsubscribe :absent, unless: :subscription_rejected?
def present
membership.present
broadcast_read_room
end
def absent
membership.disconnected
end
def refresh
membership.refresh_connection
... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/channels/typing_notifications_channel.rb | app/channels/typing_notifications_channel.rb | class TypingNotificationsChannel < RoomChannel
def start(data)
broadcast_to @room, action: :start, user: current_user_attributes
end
def stop(data)
broadcast_to @room, action: :stop, user: current_user_attributes
end
private
def current_user_attributes
current_user.slice(:id, :name)
en... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/channels/heartbeat_channel.rb | app/channels/heartbeat_channel.rb | class HeartbeatChannel < ApplicationCable::Channel
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/channels/room_channel.rb | app/channels/room_channel.rb | class RoomChannel < ApplicationCable::Channel
def subscribed
if @room = find_room
stream_for @room
else
reject
end
end
private
def find_room
current_user.rooms.find_by(id: params[:room_id])
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/channels/application_cable/channel.rb | app/channels/application_cable/channel.rb | module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/app/channels/application_cable/connection.rb | app/channels/application_cable/connection.rb | module ApplicationCable
class Connection < ActionCable::Connection::Base
include Authentication::SessionLookup
identified_by :current_user
def connect
self.current_user = find_verified_user
end
private
def find_verified_user
if verified_session = find_session_by_cookie
... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/db/schema.rb | db/schema.rb | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/db/migrate/20231215043540_create_initial_schema.rb | db/migrate/20231215043540_create_initial_schema.rb | class CreateInitialSchema < ActiveRecord::Migration[7.2]
def change
create_table "accounts", force: :cascade do |t|
t.string "name", null: false
t.string "join_code", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "action_tex... | ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/db/migrate/20240130003150_create_webhooks.rb | db/migrate/20240130003150_create_webhooks.rb | class CreateWebhooks < ActiveRecord::Migration[7.2]
def change
create_table :webhooks do |t|
t.references :user, null: false, foreign_key: true
t.string :url
t.timestamps
end
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/db/migrate/20251126092013_create_bans.rb | db/migrate/20251126092013_create_bans.rb | class CreateBans < ActiveRecord::Migration[8.1]
def change
create_table :bans do |t|
t.references :user, null: false, foreign_key: true
t.string :ip_address, null: false
t.timestamps
end
add_index :bans, :ip_address
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
basecamp/once-campfire | https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/db/migrate/20240209110503_alter_users_add_bot_token.rb | db/migrate/20240209110503_alter_users_add_bot_token.rb | class AlterUsersAddBotToken < ActiveRecord::Migration[7.2]
def change
add_column :users, :bot_token, :string
add_index :users, :bot_token, unique: true
# Bot users do not use passwords
change_column_null :users, :password_digest, true
end
end
| ruby | MIT | 1852adb06c125ac45253f2f0785ce3747694f448 | 2026-01-04T15:48:40.201016Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.