current task: where the fuck does the glitch-soc code actually determine if a post is local only
code
oh ok, in app/models/status.rb
:
'''
before_create :set_locality
'''
and then in there
'''
def set_locality
if account.domain.nil? && !attribute_changed?(:local_only)
self.local_only = marked_local_only?
end
end
'''
and a couple paragraphs above that:
'''
def marked_local_only?
# match both with and without U+FE0F (the emoji variation selector)
/#{local_only_emoji}\ufe0f?\z/.match?(content)
end
def local_only_emoji
'👁'
end
'''
re: code
before_create is a callback on ActiveRecords---https://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html
re: code
it gets invoked when an ActiveRecord is saved
@starfall ty
@starfall feel silly for not looking in the fucking model for a status
@aescling i mean, that's not where we'd have expected it either
mostly due to our experience with enterprise java, which tries to be as non-object-oriented as possible
@starfall yeah it does feel like code i would put in a service layer
@aescling and that is why i say very few people are writing object-oriented java in practice, it's just remote procedure calls with objects that ought as well be structs
interesting differences from what we learned at uni lol
@aescling it figures it out by whether the last character is 👁️
i have to write some more character after that, for obvious reasons
@monorail that’s what i understood, but i cannot yet find where it actually does this in the codebase
@monorail oh my god it’s in the model definition for a status. lol
@aescling ah I see
re: why is that not code blocks
@aescling backticks ` make code blocks
also maybe tildes?
not sure but if this follows commonmark spec it should
it looks for a sigil, right? where though.